This patch series enable the usb gadget support on at91sam9n12ek
board. On at91sam9n12 SoC which integrate the full speed udc device.
Bo Shen (3):
USB: gadget: at91_udc: add at91sam9n12 support
ARM: at91: dt: at91sam9n12: add udp device node
ARM: at91: dt: at91sam9n12ek: enable udp
arch/arm/boot/dts/at91sam9n12.dtsi | 9 +++++++++
arch/arm/boot/dts/at91sam9n12ek.dts | 5 +++++
drivers/usb/gadget/udc/at91_udc.c | 9 ++++++---
3 files changed, 20 insertions(+), 3 deletions(-)
--
2.3.0.rc0
Add at91sam9n12 SoC support.
Signed-off-by: Bo Shen <[email protected]>
---
drivers/usb/gadget/udc/at91_udc.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/gadget/udc/at91_udc.c b/drivers/usb/gadget/udc/at91_udc.c
index c862656..f4c785f 100644
--- a/drivers/usb/gadget/udc/at91_udc.c
+++ b/drivers/usb/gadget/udc/at91_udc.c
@@ -931,7 +931,8 @@ static void pullup(struct at91_udc *udc, int is_on)
at91_udp_write(udc, AT91_UDP_TXVC, 0);
if (cpu_is_at91rm9200())
gpio_set_value(udc->board.pullup_pin, active);
- else if (cpu_is_at91sam9260() || cpu_is_at91sam9263() || cpu_is_at91sam9g20()) {
+ else if (cpu_is_at91sam9260() || cpu_is_at91sam9263() ||
+ cpu_is_at91sam9g20() || cpu_is_at91sam9n12()) {
u32 txvc = at91_udp_read(udc, AT91_UDP_TXVC);
txvc |= AT91_UDP_TXVC_PUON;
@@ -949,7 +950,8 @@ static void pullup(struct at91_udc *udc, int is_on)
at91_udp_write(udc, AT91_UDP_TXVC, AT91_UDP_TXVC_TXVDIS);
if (cpu_is_at91rm9200())
gpio_set_value(udc->board.pullup_pin, !active);
- else if (cpu_is_at91sam9260() || cpu_is_at91sam9263() || cpu_is_at91sam9g20()) {
+ else if (cpu_is_at91sam9260() || cpu_is_at91sam9263() ||
+ cpu_is_at91sam9g20() || cpu_is_at91sam9n12()) {
u32 txvc = at91_udp_read(udc, AT91_UDP_TXVC);
txvc &= ~AT91_UDP_TXVC_PUON;
@@ -1758,7 +1760,8 @@ static int at91udc_probe(struct platform_device *pdev)
}
/* newer chips have more FIFO memory than rm9200 */
- if (cpu_is_at91sam9260() || cpu_is_at91sam9g20()) {
+ if (cpu_is_at91sam9260() || cpu_is_at91sam9g20() ||
+ cpu_is_at91sam9n12()) {
udc->ep[0].maxpacket = 64;
udc->ep[3].maxpacket = 64;
udc->ep[4].maxpacket = 512;
--
2.3.0.rc0
Add usb device node for at91sam9n12.
Signed-off-by: Bo Shen <[email protected]>
---
arch/arm/boot/dts/at91sam9n12.dtsi | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/arch/arm/boot/dts/at91sam9n12.dtsi b/arch/arm/boot/dts/at91sam9n12.dtsi
index 68eb9ad..6120e03 100644
--- a/arch/arm/boot/dts/at91sam9n12.dtsi
+++ b/arch/arm/boot/dts/at91sam9n12.dtsi
@@ -901,6 +901,15 @@
clocks = <&pwm_clk>;
status = "disabled";
};
+
+ usb1: gadget@f803c000 {
+ compatible = "atmel,at91rm9200-udc";
+ reg = <0xf803c000 0x4000>;
+ interrupts = <23 IRQ_TYPE_LEVEL_HIGH 2>;
+ clocks = <&usb>, <&udphs_clk>, <&udpck>;
+ clock-names = "usb_clk", "udc_clk", "udpck";
+ status = "disabled";
+ };
};
nand0: nand@40000000 {
--
2.3.0.rc0
Enable usb device port on at91sam9n12ek board.
Signed-off-by: Bo Shen <[email protected]>
---
arch/arm/boot/dts/at91sam9n12ek.dts | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/arch/arm/boot/dts/at91sam9n12ek.dts b/arch/arm/boot/dts/at91sam9n12ek.dts
index 13bb24e..3e572e5 100644
--- a/arch/arm/boot/dts/at91sam9n12ek.dts
+++ b/arch/arm/boot/dts/at91sam9n12ek.dts
@@ -120,6 +120,11 @@
};
};
+ usb1: gadget@f803c000 {
+ atmel,vbus-gpio = <&pioB 16 GPIO_ACTIVE_HIGH>;
+ status = "okay";
+ };
+
watchdog@fffffe40 {
status = "okay";
};
--
2.3.0.rc0
Hello Bo,
On Mon, Feb 09, 2015 at 05:02:52PM +0800, Bo Shen wrote:
> Enable usb device port on at91sam9n12ek board.
>
> Signed-off-by: Bo Shen <[email protected]>
> ---
>
> arch/arm/boot/dts/at91sam9n12ek.dts | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/arch/arm/boot/dts/at91sam9n12ek.dts b/arch/arm/boot/dts/at91sam9n12ek.dts
> index 13bb24e..3e572e5 100644
> --- a/arch/arm/boot/dts/at91sam9n12ek.dts
> +++ b/arch/arm/boot/dts/at91sam9n12ek.dts
> @@ -120,6 +120,11 @@
> };
> };
>
> + usb1: gadget@f803c000 {
> + atmel,vbus-gpio = <&pioB 16 GPIO_ACTIVE_HIGH>;
> + status = "okay";
> + };
> +
There is an external resistor divider on PB16, acting like a pull-down
(R22+R23). PB16 reset state is input, pull-up, schmitt trigger, you need
to disable the pull-up in pinctrl this way:
usb1: gadget@f803c000 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_board_usb1>;
…
}
pinctrl … {
usb1 {
pinctrl_board_usb1: usb1-board {
atmel,pins = <AT91_PIOB 16 AT91_PERIPH_GPIO AT91_PINCTRL_DEGLITCH>; /* PB16, no pull up and deglitch */
};
};
};
Sylvain
Hi Sylvain,
On 02/09/2015 06:04 PM, Sylvain Rochet wrote:
> Hello Bo,
>
> On Mon, Feb 09, 2015 at 05:02:52PM +0800, Bo Shen wrote:
>> Enable usb device port on at91sam9n12ek board.
>>
>> Signed-off-by: Bo Shen <[email protected]>
>> ---
>>
>> arch/arm/boot/dts/at91sam9n12ek.dts | 5 +++++
>> 1 file changed, 5 insertions(+)
>>
>> diff --git a/arch/arm/boot/dts/at91sam9n12ek.dts b/arch/arm/boot/dts/at91sam9n12ek.dts
>> index 13bb24e..3e572e5 100644
>> --- a/arch/arm/boot/dts/at91sam9n12ek.dts
>> +++ b/arch/arm/boot/dts/at91sam9n12ek.dts
>> @@ -120,6 +120,11 @@
>> };
>> };
>>
>> + usb1: gadget@f803c000 {
>> + atmel,vbus-gpio = <&pioB 16 GPIO_ACTIVE_HIGH>;
>> + status = "okay";
>> + };
>> +
>
> There is an external resistor divider on PB16, acting like a pull-down
> (R22+R23). PB16 reset state is input, pull-up, schmitt trigger, you need
> to disable the pull-up in pinctrl this way:
>
> usb1: gadget@f803c000 {
> pinctrl-names = "default";
> pinctrl-0 = <&pinctrl_board_usb1>;
> …
> }
>
> pinctrl … {
> usb1 {
> pinctrl_board_usb1: usb1-board {
> atmel,pins = <AT91_PIOB 16 AT91_PERIPH_GPIO AT91_PINCTRL_DEGLITCH>; /* PB16, no pull up and deglitch */
> };
> };
> };
Thanks.
I will add it in next version.
>
> Sylvain
>
Best Regards,
Bo Shen
Hi Bo,
On 09/02/2015 at 17:02:50 +0800, Bo Shen wrote :
> Add at91sam9n12 SoC support.
>
> Signed-off-by: Bo Shen <[email protected]>
> ---
>
> drivers/usb/gadget/udc/at91_udc.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/usb/gadget/udc/at91_udc.c b/drivers/usb/gadget/udc/at91_udc.c
> index c862656..f4c785f 100644
> --- a/drivers/usb/gadget/udc/at91_udc.c
> +++ b/drivers/usb/gadget/udc/at91_udc.c
> @@ -931,7 +931,8 @@ static void pullup(struct at91_udc *udc, int is_on)
> at91_udp_write(udc, AT91_UDP_TXVC, 0);
> if (cpu_is_at91rm9200())
> gpio_set_value(udc->board.pullup_pin, active);
> - else if (cpu_is_at91sam9260() || cpu_is_at91sam9263() || cpu_is_at91sam9g20()) {
> + else if (cpu_is_at91sam9260() || cpu_is_at91sam9263() ||
> + cpu_is_at91sam9g20() || cpu_is_at91sam9n12()) {
cpu_is_at91xx have been removed from the kernel, using the correct
compatible should be enough, see
http://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/commit/drivers/usb/gadget/udc/at91_udc.c?id=f0bceab4e3b528e799aba8fda8d2936fcfd41f1f
> u32 txvc = at91_udp_read(udc, AT91_UDP_TXVC);
>
> txvc |= AT91_UDP_TXVC_PUON;
> @@ -949,7 +950,8 @@ static void pullup(struct at91_udc *udc, int is_on)
> at91_udp_write(udc, AT91_UDP_TXVC, AT91_UDP_TXVC_TXVDIS);
> if (cpu_is_at91rm9200())
> gpio_set_value(udc->board.pullup_pin, !active);
> - else if (cpu_is_at91sam9260() || cpu_is_at91sam9263() || cpu_is_at91sam9g20()) {
> + else if (cpu_is_at91sam9260() || cpu_is_at91sam9263() ||
> + cpu_is_at91sam9g20() || cpu_is_at91sam9n12()) {
> u32 txvc = at91_udp_read(udc, AT91_UDP_TXVC);
>
> txvc &= ~AT91_UDP_TXVC_PUON;
> @@ -1758,7 +1760,8 @@ static int at91udc_probe(struct platform_device *pdev)
> }
>
> /* newer chips have more FIFO memory than rm9200 */
> - if (cpu_is_at91sam9260() || cpu_is_at91sam9g20()) {
> + if (cpu_is_at91sam9260() || cpu_is_at91sam9g20() ||
> + cpu_is_at91sam9n12()) {
> udc->ep[0].maxpacket = 64;
> udc->ep[3].maxpacket = 64;
> udc->ep[4].maxpacket = 512;
> --
> 2.3.0.rc0
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> [email protected]
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
--
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
Hi Alexandre,
On 02/09/2015 07:14 PM, Alexandre Belloni wrote:
> Hi Bo,
>
> On 09/02/2015 at 17:02:50 +0800, Bo Shen wrote :
>> Add at91sam9n12 SoC support.
>>
>> Signed-off-by: Bo Shen <[email protected]>
>> ---
>>
>> drivers/usb/gadget/udc/at91_udc.c | 9 ++++++---
>> 1 file changed, 6 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/usb/gadget/udc/at91_udc.c b/drivers/usb/gadget/udc/at91_udc.c
>> index c862656..f4c785f 100644
>> --- a/drivers/usb/gadget/udc/at91_udc.c
>> +++ b/drivers/usb/gadget/udc/at91_udc.c
>> @@ -931,7 +931,8 @@ static void pullup(struct at91_udc *udc, int is_on)
>> at91_udp_write(udc, AT91_UDP_TXVC, 0);
>> if (cpu_is_at91rm9200())
>> gpio_set_value(udc->board.pullup_pin, active);
>> - else if (cpu_is_at91sam9260() || cpu_is_at91sam9263() || cpu_is_at91sam9g20()) {
>> + else if (cpu_is_at91sam9260() || cpu_is_at91sam9263() ||
>> + cpu_is_at91sam9g20() || cpu_is_at91sam9n12()) {
>
> cpu_is_at91xx have been removed from the kernel, using the correct
> compatible should be enough, see
> http://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/commit/drivers/usb/gadget/udc/at91_udc.c?id=f0bceab4e3b528e799aba8fda8d2936fcfd41f1f
Thanks for you information. Missing this patch, check the next-20150209,
it is here. I will base on next-20150209, so this patch no need anymore,
only need to change the dts(i) file now.
Thanks again.
>
>> u32 txvc = at91_udp_read(udc, AT91_UDP_TXVC);
>>
>> txvc |= AT91_UDP_TXVC_PUON;
>> @@ -949,7 +950,8 @@ static void pullup(struct at91_udc *udc, int is_on)
>> at91_udp_write(udc, AT91_UDP_TXVC, AT91_UDP_TXVC_TXVDIS);
>> if (cpu_is_at91rm9200())
>> gpio_set_value(udc->board.pullup_pin, !active);
>> - else if (cpu_is_at91sam9260() || cpu_is_at91sam9263() || cpu_is_at91sam9g20()) {
>> + else if (cpu_is_at91sam9260() || cpu_is_at91sam9263() ||
>> + cpu_is_at91sam9g20() || cpu_is_at91sam9n12()) {
>> u32 txvc = at91_udp_read(udc, AT91_UDP_TXVC);
>>
>> txvc &= ~AT91_UDP_TXVC_PUON;
>> @@ -1758,7 +1760,8 @@ static int at91udc_probe(struct platform_device *pdev)
>> }
>>
>> /* newer chips have more FIFO memory than rm9200 */
>> - if (cpu_is_at91sam9260() || cpu_is_at91sam9g20()) {
>> + if (cpu_is_at91sam9260() || cpu_is_at91sam9g20() ||
>> + cpu_is_at91sam9n12()) {
>> udc->ep[0].maxpacket = 64;
>> udc->ep[3].maxpacket = 64;
>> udc->ep[4].maxpacket = 512;
>> --
>> 2.3.0.rc0
Best Regards,
Bo Shen