Re: [PATCH 5/6] powerpc: add USB peripheral support to MPC836xMDS
Hi Anton, On Wed, 2008-08-06 at 16:07 +0400, Anton Vorontsov wrote: Hello Li, On Wed, Aug 06, 2008 at 03:04:44PM +0800, Li Yang wrote: Signed-off-by: Li Yang [EMAIL PROTECTED] --- arch/powerpc/boot/dts/mpc836x_mds.dts | 15 ++- arch/powerpc/platforms/83xx/mpc836x_mds.c | 19 - arch/powerpc/platforms/83xx/mpc83xx.h |1 + arch/powerpc/platforms/83xx/usb.c | 67 + 4 files changed, 100 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/boot/dts/mpc836x_mds.dts b/arch/powerpc/boot/dts/mpc836x_mds.dts index a3b76a7..596377b 100644 --- a/arch/powerpc/boot/dts/mpc836x_mds.dts +++ b/arch/powerpc/boot/dts/mpc836x_mds.dts @@ -235,6 +235,17 @@ 0 2 1 0 1 0; /* MDC */ }; + pio_usb: [EMAIL PROTECTED] { + pio-map = + /* port pin dir open_drain assignment has_irq */ + 1 2 1 0 3 0/* USBOE */ + 1 3 1 0 3 0/* USBTP */ + 1 8 1 0 1 0/* USBTN */ + 1 10 2 0 3 0/* USBRXD */ + 1 9 2 1 3 0/* USBRP */ + 1 11 2 1 3 0; /* USBRN */ + }; + }; }; @@ -280,11 +291,13 @@ }; [EMAIL PROTECTED] { - compatible = qe_udc; + compatible = fsl,qe_udc; You might want to reuse existing bindings as described in Documentation/powerpc/dts-bindings/fsl/cpm_qe/qe/usb.txt. Ok. I didn't notice your addition to the binding. I will try to update it for device mode. reg = 0x6c0 0x40 0x8b00 0x100; interrupts = 11; interrupt-parent = qeic; mode = slave; I'd suggest to rename this to peripheral as we use for fsl dual-role usb controller. As there will be two drivers chosen by compatible, I'm now inclined to put this information in compatible. + usb-clock = 21; + pio-handle = pio_usb; Can we not introduce new pio maps? The pio setup should be done by the firmware, or at least fixed up via the board file, as in arch/powerpc/platforms/83xx/mpc832x_rdb.c. Actually I am more apt to leaving full hardware access to kernel than firmware, especially for devices that are not used in firmware. The reason why I made the pin-configuration flexible is that for development boards the role of pins are often changeable. [...] +#ifdef CONFIG_QUICC_ENGINE +/* QE USB_CLOCK configure functions */ +int qe_usb_clock_set(struct device_node *np) We already have this function, in arch/powerpc/sysdev/qe_lib/usb.c I just saw this. Will try to reuse it. It does not parse any of properties though, driver should do this. +{ + u32 tmpreg = 0; + struct qe_mux *qemux = NULL; + const int *clock; + + qemux = qe_immr-qmx; + + clock = of_get_property(np, usb-clock, NULL); + if (!clock) + return -EINVAL; + + /* CLK21 - USBCLK on MPC8360-PB*/ + tmpreg = in_be32(qemux-cmxgcr) ~QE_CMXGCR_USBCS; + switch (*clock) { + case 21: + tmpreg |= 0x8; + out_be32(qemux-cmxgcr, tmpreg); + par_io_config_pin(2, 20, 2, 0, 1, 0); /* PC20 for CLK21 */ No, pio config is very board-specific. This should be done by the firmware (ideally) or by the board file. Pio config is board and board configuration specific. It's better to make it configurable by device tree. - Leo ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [PATCH 5/6] powerpc: add USB peripheral support to MPC836xMDS
On Thu, Aug 07, 2008 at 05:31:44PM +0800, Li Yang wrote: [...] reg = 0x6c0 0x40 0x8b00 0x100; interrupts = 11; interrupt-parent = qeic; mode = slave; I'd suggest to rename this to peripheral as we use for fsl dual-role usb controller. As there will be two drivers chosen by compatible, I'm now inclined to put this information in compatible. Please don't. I deliberately wrote bindings w/o specifing udc or host in the compatible entry. udc/host is the modes of an USB controller, but the controller itself is the same: fsl,mpc8323-qe-usb (the first chip with QE USB). So the driver should always match this device, but it can return -ENODEV if mode is unspecified or !peripheral. + usb-clock = 21; + pio-handle = pio_usb; Can we not introduce new pio maps? The pio setup should be done by the firmware, or at least fixed up via the board file, as in arch/powerpc/platforms/83xx/mpc832x_rdb.c. Actually I am more apt to leaving full hardware access to kernel than firmware, especially for devices that are not used in firmware. The reason why I made the pin-configuration flexible is that for development boards the role of pins are often changeable. [...] Pio config is board and board configuration specific. It's better to make it configurable by device tree. Device tree isn't configuration file. The bad thing about pio-map is that it is passing raw values instead of actually describing the hardware. For example, pio-map = 1 6 2 0 1 0; The thing describes bankB/pin6.. but you'll can't tell what exactly this pin supposed to do. :-/ Basically pio-map is expanded version of this: fsl,cpodr-reg = 0x...; fsl,cppar1-reg = 0x...; fsl,cppar2-reg = 0x...; ... Instead, it would be great to have something like this: [EMAIL PROTECTED] { /* * gpio/pinmuxpin * controller */ pio-map = pinmuxA 1 /* bindings says first pin is clk */ pinmuxB14 /* bindings says second pin is usboe */ ...; }; [EMAIL PROTECTED] { pio-map = pinmuxA 2 /* bindings says first pin is clk */ pinmuxB24 /* bindings says second pin is rxd0 */ pinmuxB21 /* bindings says second pin is rxd1 */ ...; }; Then drivers would call something like this in probe(): clk = qe_get_clock(node, fsl,fullspeed-clock); qe_set_pinmux(pin0, QE_PIN_FUNC_CLK(clk)); qe_set_pinmux(pin1, QE_PIN_FUNC_USB_OE); ...or ucc ethernet... qe_set_pinmux(pin[rx_n], QE_PIN_FUNC_UCC_RXD(ucc_num, rx_n)); Obviously, this is quite hard to implement (and expensive, too), since each SoC implementation has its own function-pin-regvalue mapping.. Thus nobody even think to bother with this. Anyway, I'm not that opposed to the current pio-maps, but it would be great if we could avoid them where possible. -- Anton Vorontsov email: [EMAIL PROTECTED] irc://irc.freenode.net/bd2 ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
[PATCH 5/6] powerpc: add USB peripheral support to MPC836xMDS
Signed-off-by: Li Yang [EMAIL PROTECTED] --- arch/powerpc/boot/dts/mpc836x_mds.dts | 15 ++- arch/powerpc/platforms/83xx/mpc836x_mds.c | 19 - arch/powerpc/platforms/83xx/mpc83xx.h |1 + arch/powerpc/platforms/83xx/usb.c | 67 + 4 files changed, 100 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/boot/dts/mpc836x_mds.dts b/arch/powerpc/boot/dts/mpc836x_mds.dts index a3b76a7..596377b 100644 --- a/arch/powerpc/boot/dts/mpc836x_mds.dts +++ b/arch/powerpc/boot/dts/mpc836x_mds.dts @@ -235,6 +235,17 @@ 0 2 1 0 1 0; /* MDC */ }; + pio_usb: [EMAIL PROTECTED] { + pio-map = + /* port pin dir open_drain assignment has_irq */ + 1 2 1 0 3 0/* USBOE */ + 1 3 1 0 3 0/* USBTP */ + 1 8 1 0 1 0/* USBTN */ + 1 10 2 0 3 0/* USBRXD */ + 1 9 2 1 3 0/* USBRP */ + 1 11 2 1 3 0; /* USBRN */ + }; + }; }; @@ -280,11 +291,13 @@ }; [EMAIL PROTECTED] { - compatible = qe_udc; + compatible = fsl,qe_udc; reg = 0x6c0 0x40 0x8b00 0x100; interrupts = 11; interrupt-parent = qeic; mode = slave; + usb-clock = 21; + pio-handle = pio_usb; }; enet0: [EMAIL PROTECTED] { diff --git a/arch/powerpc/platforms/83xx/mpc836x_mds.c b/arch/powerpc/platforms/83xx/mpc836x_mds.c index 9d46e5b..92afd40 100644 --- a/arch/powerpc/platforms/83xx/mpc836x_mds.c +++ b/arch/powerpc/platforms/83xx/mpc836x_mds.c @@ -93,6 +93,12 @@ static void __init mpc836x_mds_setup_arch(void) for (np = NULL; (np = of_find_node_by_name(np, ucc)) != NULL;) par_io_of_config(np); + + np = of_find_compatible_node(NULL, NULL, fsl,qe_udc); + if (np) { + par_io_of_config(np); + qe_usb_clock_set(np); + } } if ((np = of_find_compatible_node(NULL, network, ucc_geth)) @@ -127,9 +133,20 @@ static void __init mpc836x_mds_setup_arch(void) iounmap(immap); } - iounmap(bcsr_regs); of_node_put(np); } + + np = of_find_compatible_node(NULL, NULL, fsl,qe_udc); + if (np != NULL) { + /* Set the TESCs run on RGMII mode */ + bcsr_regs[8] = ~0xf0; + /* Enable the USB Device PHY */ + bcsr_regs[13] = ~0x0f; + udelay(1000); + bcsr_regs[13] |= 0x05; + of_node_put(np); + } + iounmap(bcsr_regs); #endif /* CONFIG_QUICC_ENGINE */ } diff --git a/arch/powerpc/platforms/83xx/mpc83xx.h b/arch/powerpc/platforms/83xx/mpc83xx.h index 2a7cbab..d025b47 100644 --- a/arch/powerpc/platforms/83xx/mpc83xx.h +++ b/arch/powerpc/platforms/83xx/mpc83xx.h @@ -63,5 +63,6 @@ extern void mpc83xx_restart(char *cmd); extern long mpc83xx_time_init(void); extern int mpc834x_usb_cfg(void); extern int mpc831x_usb_cfg(void); +extern int qe_usb_clock_set(struct device_node *np); #endif /* __MPC83XX_H__ */ diff --git a/arch/powerpc/platforms/83xx/usb.c b/arch/powerpc/platforms/83xx/usb.c index cc99c28..3d04ab5 100644 --- a/arch/powerpc/platforms/83xx/usb.c +++ b/arch/powerpc/platforms/83xx/usb.c @@ -18,6 +18,7 @@ #include asm/io.h #include asm/prom.h #include sysdev/fsl_soc.h +#include asm/qe.h #include mpc83xx.h @@ -240,3 +241,69 @@ int mpc837x_usb_cfg(void) return ret; } #endif /* CONFIG_PPC_MPC837x */ + +#ifdef CONFIG_QUICC_ENGINE +/* QE USB_CLOCK configure functions */ +int qe_usb_clock_set(struct device_node *np) +{ + u32 tmpreg = 0; + struct qe_mux *qemux = NULL; + const int *clock; + + qemux = qe_immr-qmx; + + clock = of_get_property(np, usb-clock, NULL); + if (!clock) + return -EINVAL; + + /* CLK21 - USBCLK on MPC8360-PB*/ + tmpreg = in_be32(qemux-cmxgcr) ~QE_CMXGCR_USBCS; + switch (*clock) { + case 21: + tmpreg |= 0x8; + out_be32(qemux-cmxgcr, tmpreg); + par_io_config_pin(2, 20, 2, 0, 1, 0); /* PC20 for CLK21 */ + break; + case 19: + tmpreg |= 0x7; + out_be32(qemux-cmxgcr, tmpreg); + par_io_config_pin(2, 18, 2, 0, 1, 0); /*
Re: [PATCH 5/6] powerpc: add USB peripheral support to MPC836xMDS
Hi Li, On Wed, 6 Aug 2008 15:04:44 +0800 Li Yang [EMAIL PROTECTED] wrote: @@ -93,6 +93,12 @@ static void __init mpc836x_mds_setup_arch(void) for (np = NULL; (np = of_find_node_by_name(np, ucc)) != NULL;) par_io_of_config(np); + + np = of_find_compatible_node(NULL, NULL, fsl,qe_udc); + if (np) { + par_io_of_config(np); + qe_usb_clock_set(np); of_node_put(np); + } -- Cheers, Stephen Rothwell[EMAIL PROTECTED] http://www.canb.auug.org.au/~sfr/ pgpdR9mfLPshr.pgp Description: PGP signature ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [PATCH 5/6] powerpc: add USB peripheral support to MPC836xMDS
Hello Li, On Wed, Aug 06, 2008 at 03:04:44PM +0800, Li Yang wrote: Signed-off-by: Li Yang [EMAIL PROTECTED] --- arch/powerpc/boot/dts/mpc836x_mds.dts | 15 ++- arch/powerpc/platforms/83xx/mpc836x_mds.c | 19 - arch/powerpc/platforms/83xx/mpc83xx.h |1 + arch/powerpc/platforms/83xx/usb.c | 67 + 4 files changed, 100 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/boot/dts/mpc836x_mds.dts b/arch/powerpc/boot/dts/mpc836x_mds.dts index a3b76a7..596377b 100644 --- a/arch/powerpc/boot/dts/mpc836x_mds.dts +++ b/arch/powerpc/boot/dts/mpc836x_mds.dts @@ -235,6 +235,17 @@ 0 2 1 0 1 0; /* MDC */ }; + pio_usb: [EMAIL PROTECTED] { + pio-map = + /* port pin dir open_drain assignment has_irq */ + 1 2 1 0 3 0/* USBOE */ + 1 3 1 0 3 0/* USBTP */ + 1 8 1 0 1 0/* USBTN */ + 1 10 2 0 3 0/* USBRXD */ + 1 9 2 1 3 0/* USBRP */ + 1 11 2 1 3 0; /* USBRN */ + }; + }; }; @@ -280,11 +291,13 @@ }; [EMAIL PROTECTED] { - compatible = qe_udc; + compatible = fsl,qe_udc; You might want to reuse existing bindings as described in Documentation/powerpc/dts-bindings/fsl/cpm_qe/qe/usb.txt. reg = 0x6c0 0x40 0x8b00 0x100; interrupts = 11; interrupt-parent = qeic; mode = slave; I'd suggest to rename this to peripheral as we use for fsl dual-role usb controller. + usb-clock = 21; + pio-handle = pio_usb; Can we not introduce new pio maps? The pio setup should be done by the firmware, or at least fixed up via the board file, as in arch/powerpc/platforms/83xx/mpc832x_rdb.c. [...] +#ifdef CONFIG_QUICC_ENGINE +/* QE USB_CLOCK configure functions */ +int qe_usb_clock_set(struct device_node *np) We already have this function, in arch/powerpc/sysdev/qe_lib/usb.c It does not parse any of properties though, driver should do this. +{ + u32 tmpreg = 0; + struct qe_mux *qemux = NULL; + const int *clock; + + qemux = qe_immr-qmx; + + clock = of_get_property(np, usb-clock, NULL); + if (!clock) + return -EINVAL; + + /* CLK21 - USBCLK on MPC8360-PB*/ + tmpreg = in_be32(qemux-cmxgcr) ~QE_CMXGCR_USBCS; + switch (*clock) { + case 21: + tmpreg |= 0x8; + out_be32(qemux-cmxgcr, tmpreg); + par_io_config_pin(2, 20, 2, 0, 1, 0); /* PC20 for CLK21 */ No, pio config is very board-specific. This should be done by the firmware (ideally) or by the board file. Thanks, -- Anton Vorontsov email: [EMAIL PROTECTED] irc://irc.freenode.net/bd2 ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [PATCH 5/6] powerpc: add USB peripheral support to MPC836xMDS
On Wed, Aug 06, 2008 at 03:04:44PM +0800, Li Yang wrote: [EMAIL PROTECTED] { - compatible = qe_udc; + compatible = fsl,qe_udc; [snip] + + np = of_find_compatible_node(NULL, NULL, fsl,qe_udc); + if (np) { + par_io_of_config(np); + qe_usb_clock_set(np); + } What about existing device trees in use? + printk(KERN_ERR Unsupport usb-clock input pin\n); s/Unsupport/Unsupported/ -Scott ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [PATCH 5/6] powerpc: add USB peripheral support to MPC836xMDS
On Wed, 2008-08-06 at 12:29 -0500, Scott Wood wrote: On Wed, Aug 06, 2008 at 03:04:44PM +0800, Li Yang wrote: [EMAIL PROTECTED] { - compatible = qe_udc; + compatible = fsl,qe_udc; [snip] + + np = of_find_compatible_node(NULL, NULL, fsl,qe_udc); + if (np) { + par_io_of_config(np); + qe_usb_clock_set(np); + } What about existing device trees in use? This node was never used in existing device trees for mainline kernel. - Leo ___ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev