aboutsummaryrefslogtreecommitdiffstats
path: root/tools
Commit message (Expand)AuthorAgeFilesLines
* target/linux/orion: create subtargets (closes #8154)Alexandros C. Couloumbis2010-11-041-2/+2
* ensure an empty BUILD_DIR variable is passed down u-boot's makefileMichael Büsch2010-11-031-1/+1
* add a stripped down (and portable) version of flock to the host toolsFelix Fietkau2010-10-293-1/+348
* tools/mtd-utils: add two upstream patchesAlexandros C. Couloumbis2010-10-152-0/+193
* quilt: pass PATH and FIND to configure (FreeBSD compatibility)Jo-Philipp Wich2010-10-071-0/+4
* reenable squashfs4 for ar71xx, it needs both old and newJo-Philipp Wich2010-10-061-1/+2
* ipkg-utils: don't fail if conffiles do not exist, resolve them instead and si...Jo-Philipp Wich2010-10-051-0/+23
* Toto, we don't support Linux 2.4 anymore..Imre Kaloz2010-10-051-1/+1
* simplify old squashfs/lzma selectionImre Kaloz2010-10-051-4/+1
* tools/sed: update to sed-4.2.1 (also tested on FreeBSD/AMD64)Alexandros C. Couloumbis2010-10-052-17/+5
* mtd-utils: refresh patches againJo-Philipp Wich2010-10-032-3/+3
* tools/mtd-utils: fix build issue under freebsd. update to latest git tree. (t...Alexandros C. Couloumbis2010-10-031-6/+6
* tools/mtd-utils: kill 132-revert-zlib-cleanup.patch. it's wrong.Alexandros C. Couloumbis2010-10-031-210/+0
* libuuid: Use libuuid from util-linux-ng instead of e2fsprogsLars-Peter Clausen2010-10-022-2009/+52
* mtd-utils: refresh patchesJo-Philipp Wich2010-10-025-60/+56
* tools/mtd-utils: fix compilation on OS XJo-Philipp Wich2010-10-021-10/+10
* tools/mtd-utils: update to mtd-utils-20101001, fix FreeBSD (and hopefully Dar...Alexandros C. Couloumbis2010-10-0110-56/+293
* firmware-utils/mktplinkfw: add support for the TL-MR3420 v1Gabor Juhos2010-09-271-0/+9
* firmware-utils/mktplinkfw: add support for the TL-WR841N v7Gabor Juhos2010-09-271-0/+9
* mtd-utils: revert r23075Jo-Philipp Wich2010-09-152-38/+39
* mtd-utils: do not rely on host kernel headers, redefine the integer types ins...Jo-Philipp Wich2010-09-152-39/+38
* revert r23048 for now until Darwin compile issues have been sorted out (#7934)Jo-Philipp Wich2010-09-136-47/+43
* tools/mtd-utils: update to version git-20100912Alexandros C. Couloumbis2010-09-136-43/+47
* fix build error in tools on darwin on newer macs (patch by dirtyfreebooter)Felix Fietkau2010-09-054-20/+0
* Zcomax device firmware tool endianness fixMichael Büsch2010-09-041-1/+1
* tools/firmware-utils: new tool for the Zcomax devicesGabor Juhos2010-09-032-0/+409
* add a command for printing a cleaned up make target database - will be used t...Felix Fietkau2010-09-011-0/+2
* qemu: add dependency on libuuidAndy Boyett2010-08-221-0/+1
* qemu: fix build failure on some systems. Closes #7767Andy Boyett2010-08-211-4/+2
* quilt: needs autoconfAndy Boyett2010-08-141-2/+2
* update wrt350nv2 builder to v2.3 (#7580)Florian Fainelli2010-08-102-17/+49
* qemu: build qemu-img for packaging vmdk and vdi imagesAndy Boyett2010-08-092-0/+42
* brcm47xx: Add new image generation and fix leds/reset button on WNR834B V2Hauke Mehrtens2010-08-062-0/+328
* sed: fix compilation on FreeBSD/AMD64Jo-Philipp Wich2010-08-061-0/+12
* mostly revert commit r22396Hauke Mehrtens2010-07-301-1/+1
* firmware-utils/trx: Endianness fixesMichael Büsch2010-07-291-4/+7
* firmware-utils: The option -F was not detected. This was missing in r22396Hauke Mehrtens2010-07-271-1/+1
* tools/quilt: fix openSUSE/patch-2.6.1.81 issue (closes #7635)Alexandros C. Couloumbis2010-07-272-0/+12
* fix CRC32 calculation for sysupgradeMarkus Wigge2010-07-271-3/+5
* squashfs4: fix compilation on FreeBSDJo-Philipp Wich2010-07-221-0/+10
* yaffs2: fix compilation on FreeBSDJo-Philipp Wich2010-07-221-0/+11
* mkimage: fix compilation on FreeBSDJo-Philipp Wich2010-07-221-1/+16
* squashfs4: backport an upstream change to fix the file mode check to allow se...Felix Fietkau2010-07-211-0/+11
* tools/firmware-utils: enhance mktplinkfw utilityGabor Juhos2010-07-131-9/+278
* firmware-utils/mktplinkfw: add support for the TL-WA901NDGabor Juhos2010-07-011-0/+9
* preset stable and try* flags for TRX2 headersMarkus Wigge2010-07-012-4/+22
* fixed trx version to handlingMarkus Wigge2010-06-281-1/+1
* remove whitespaces in imagetag toolFlorian Fainelli2010-06-201-7/+7
* Revert r21806 there are no users of it yetFlorian Fainelli2010-06-144-513/+0
* add hcsmakeimage, for cable modems/routers based on bcm33xxFlorian Fainelli2010-06-144-0/+513
>+#include <linux/bcma/bcma.h> +#include <linux/clk.h> +#include <linux/delay.h> +#include <linux/err.h> +#include <linux/module.h> +#include <linux/of_address.h> +#include <linux/of_platform.h> +#include <linux/phy/phy.h> +#include <linux/platform_device.h> +#include <linux/slab.h> + +struct bcm_ns_usb2 { + struct device *dev; + struct clk *ref_clk; + struct phy *phy; + void __iomem *dmu; +}; + +static int bcm_ns_usb2_phy_init(struct phy *phy) +{ + struct bcm_ns_usb2 *usb2 = phy_get_drvdata(phy); + struct device *dev = usb2->dev; + void __iomem *dmu = usb2->dmu; + u32 ref_clk_rate, usb2ctl, usb_pll_ndiv, usb_pll_pdiv; + int err = 0; + + err = clk_prepare_enable(usb2->ref_clk); + if (err < 0) { + dev_err(dev, "Failed to prepare ref clock: %d\n", err); + goto err_out; + } + + ref_clk_rate = clk_get_rate(usb2->ref_clk); + if (!ref_clk_rate) { + dev_err(dev, "Failed to get ref clock rate\n"); + err = -EINVAL; + goto err_clk_off; + } + + usb2ctl = readl(dmu + BCMA_DMU_CRU_USB2_CONTROL); + + if (usb2ctl & BCMA_DMU_CRU_USB2_CONTROL_USB_PLL_PDIV_MASK) { + usb_pll_pdiv = usb2ctl; + usb_pll_pdiv &= BCMA_DMU_CRU_USB2_CONTROL_USB_PLL_PDIV_MASK; + usb_pll_pdiv >>= BCMA_DMU_CRU_USB2_CONTROL_USB_PLL_PDIV_SHIFT; + } else { + usb_pll_pdiv = 1 << 3; + } + + /* Calculate ndiv based on a solid 1920 MHz that is for USB2 PHY */ + usb_pll_ndiv = (1920000000 * usb_pll_pdiv) / ref_clk_rate; + + /* Unlock DMU PLL settings with some magic value */ + writel(0x0000ea68, dmu + BCMA_DMU_CRU_CLKSET_KEY); + + /* Write USB 2.0 PLL control setting */ + usb2ctl &= ~BCMA_DMU_CRU_USB2_CONTROL_USB_PLL_NDIV_MASK; + usb2ctl |= usb_pll_ndiv << BCMA_DMU_CRU_USB2_CONTROL_USB_PLL_NDIV_SHIFT; + writel(usb2ctl, dmu + BCMA_DMU_CRU_USB2_CONTROL); + + /* Lock DMU PLL settings */ + writel(0x00000000, dmu + BCMA_DMU_CRU_CLKSET_KEY); + +err_clk_off: + clk_disable_unprepare(usb2->ref_clk); +err_out: + return err; +} + +static const struct phy_ops ops = { + .init = bcm_ns_usb2_phy_init, + .owner = THIS_MODULE, +}; + +static int bcm_ns_usb2_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct bcm_ns_usb2 *usb2; + struct resource *res; + struct phy_provider *phy_provider; + + usb2 = devm_kzalloc(&pdev->dev, sizeof(*usb2), GFP_KERNEL); + if (!usb2) + return -ENOMEM; + usb2->dev = dev; + + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dmu"); + usb2->dmu = devm_ioremap_resource(dev, res); + if (IS_ERR(usb2->dmu)) { + dev_err(dev, "Failed to map DMU regs\n"); + return PTR_ERR(usb2->dmu); + } + + usb2->ref_clk = devm_clk_get(dev, "phy-ref-clk"); + if (IS_ERR(usb2->ref_clk)) { + dev_err(dev, "Clock not defined\n"); + return PTR_ERR(usb2->ref_clk); + } + + usb2->phy = devm_phy_create(dev, NULL, &ops); + if (IS_ERR(dev)) + return PTR_ERR(dev); + + phy_set_drvdata(usb2->phy, usb2); + platform_set_drvdata(pdev, usb2); + + phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); + return PTR_ERR_OR_ZERO(phy_provider); +} + +static const struct of_device_id bcm_ns_usb2_id_table[] = { + { .compatible = "brcm,ns-usb2-phy", }, + {}, +}; +MODULE_DEVICE_TABLE(of, bcm_ns_usb2_id_table); + +static struct platform_driver bcm_ns_usb2_driver = { + .probe = bcm_ns_usb2_probe, + .driver = { + .name = "bcm_ns_usb2", + .of_match_table = bcm_ns_usb2_id_table, + }, +}; +module_platform_driver(bcm_ns_usb2_driver); + +MODULE_LICENSE("GPL v2"); --- a/include/linux/bcma/bcma.h +++ b/include/linux/bcma/bcma.h @@ -4,6 +4,7 @@ #include <linux/pci.h> #include <linux/mod_devicetable.h> +#include <linux/bcma/bcma_driver_arm_c9.h> #include <linux/bcma/bcma_driver_chipcommon.h> #include <linux/bcma/bcma_driver_pci.h> #include <linux/bcma/bcma_driver_pcie2.h> --- /dev/null +++ b/include/linux/bcma/bcma_driver_arm_c9.h @@ -0,0 +1,15 @@ +#ifndef LINUX_BCMA_DRIVER_ARM_C9_H_ +#define LINUX_BCMA_DRIVER_ARM_C9_H_ + +/* DMU (Device Management Unit) */ +#define BCMA_DMU_CRU_USB2_CONTROL 0x0164 +#define BCMA_DMU_CRU_USB2_CONTROL_USB_PLL_NDIV_MASK 0x00000FFC +#define BCMA_DMU_CRU_USB2_CONTROL_USB_PLL_NDIV_SHIFT 2 +#define BCMA_DMU_CRU_USB2_CONTROL_USB_PLL_PDIV_MASK 0x00007000 +#define BCMA_DMU_CRU_USB2_CONTROL_USB_PLL_PDIV_SHIFT 12 +#define BCMA_DMU_CRU_CLKSET_KEY 0x0180 +#define BCMA_DMU_CRU_STRAPS_CTRL 0x02A0 +#define BCMA_DMU_CRU_STRAPS_CTRL_USB3 0x00000010 +#define BCMA_DMU_CRU_STRAPS_CTRL_4BYTE 0x00008000 + +#endif /* LINUX_BCMA_DRIVER_ARM_C9_H_ */