diff options
author | Olof Johansson <olof@lixom.net> | 2012-04-05 13:43:06 -0400 |
---|---|---|
committer | Olof Johansson <olof@lixom.net> | 2012-04-05 13:43:06 -0400 |
commit | 8078342664aac3a9801a110c9a36132f592f4f37 (patch) | |
tree | 962f0435412483942236ff94650000ec0c73107a | |
parent | 98f0ec0dd4e0c96fcc7bc6dae08007820b1134a8 (diff) | |
parent | dcce6ce802c271cd7c21f4730f301150577b2826 (diff) |
Merge branch 'at91-fixes' of git://github.com/at91linux/linux-at91 into fixes
* 'at91-fixes' of git://github.com/at91linux/linux-at91:
ARM: at91: dt: remove unit-address part for memory nodes
ARM: at91: fix check of valid GPIO for SPI and USB
USB: ehci-atmel: add needed of.h header file
ARM: at91/NAND DT bindings: add comments
ARM: at91/at91sam9x5.dtsi: fix NAND ale/cle in DT file
USB: ohci-at91: trivial return code name change
USB: ohci-at91: change maximum number of ports
USB: ohci-at91: rework and fix initialization
ARM: at91/dts: USB host vbus is active low
ARM: at91/USB host: specify and handle properly vbus_pin_active_low
USB: ohci-at91: fix vbus_pin_active_low handling
ARM: at91/at91sam9x5: add clkdev entries for DMA controllers
-rw-r--r-- | Documentation/devicetree/bindings/mtd/atmel-nand.txt | 10 | ||||
-rw-r--r-- | arch/arm/boot/dts/at91sam9g20.dtsi | 2 | ||||
-rw-r--r-- | arch/arm/boot/dts/at91sam9g25ek.dts | 4 | ||||
-rw-r--r-- | arch/arm/boot/dts/at91sam9g45.dtsi | 2 | ||||
-rw-r--r-- | arch/arm/boot/dts/at91sam9m10g45ek.dts | 6 | ||||
-rw-r--r-- | arch/arm/boot/dts/at91sam9x5.dtsi | 6 | ||||
-rw-r--r-- | arch/arm/boot/dts/at91sam9x5cm.dtsi | 2 | ||||
-rw-r--r-- | arch/arm/boot/dts/usb_a9g20.dts | 2 | ||||
-rw-r--r-- | arch/arm/mach-at91/at91sam9260_devices.c | 3 | ||||
-rw-r--r-- | arch/arm/mach-at91/at91sam9261_devices.c | 3 | ||||
-rw-r--r-- | arch/arm/mach-at91/at91sam9263_devices.c | 6 | ||||
-rw-r--r-- | arch/arm/mach-at91/at91sam9g45_devices.c | 11 | ||||
-rw-r--r-- | arch/arm/mach-at91/at91sam9rl_devices.c | 3 | ||||
-rw-r--r-- | arch/arm/mach-at91/at91sam9x5.c | 2 | ||||
-rw-r--r-- | arch/arm/mach-at91/board-sam9263ek.c | 1 | ||||
-rw-r--r-- | arch/arm/mach-at91/board-sam9m10g45ek.c | 1 | ||||
-rw-r--r-- | arch/arm/mach-at91/include/mach/board.h | 13 | ||||
-rw-r--r-- | drivers/usb/host/ehci-atmel.c | 1 | ||||
-rw-r--r-- | drivers/usb/host/ohci-at91.c | 163 |
19 files changed, 137 insertions, 104 deletions
diff --git a/Documentation/devicetree/bindings/mtd/atmel-nand.txt b/Documentation/devicetree/bindings/mtd/atmel-nand.txt index 5903ecf6e895..a20069502f5a 100644 --- a/Documentation/devicetree/bindings/mtd/atmel-nand.txt +++ b/Documentation/devicetree/bindings/mtd/atmel-nand.txt | |||
@@ -27,13 +27,13 @@ nand0: nand@40000000,0 { | |||
27 | reg = <0x40000000 0x10000000 | 27 | reg = <0x40000000 0x10000000 |
28 | 0xffffe800 0x200 | 28 | 0xffffe800 0x200 |
29 | >; | 29 | >; |
30 | atmel,nand-addr-offset = <21>; | 30 | atmel,nand-addr-offset = <21>; /* ale */ |
31 | atmel,nand-cmd-offset = <22>; | 31 | atmel,nand-cmd-offset = <22>; /* cle */ |
32 | nand-on-flash-bbt; | 32 | nand-on-flash-bbt; |
33 | nand-ecc-mode = "soft"; | 33 | nand-ecc-mode = "soft"; |
34 | gpios = <&pioC 13 0 | 34 | gpios = <&pioC 13 0 /* rdy */ |
35 | &pioC 14 0 | 35 | &pioC 14 0 /* nce */ |
36 | 0 | 36 | 0 /* cd */ |
37 | >; | 37 | >; |
38 | partition@0 { | 38 | partition@0 { |
39 | ... | 39 | ... |
diff --git a/arch/arm/boot/dts/at91sam9g20.dtsi b/arch/arm/boot/dts/at91sam9g20.dtsi index 92f36627e7f8..799ad1889b51 100644 --- a/arch/arm/boot/dts/at91sam9g20.dtsi +++ b/arch/arm/boot/dts/at91sam9g20.dtsi | |||
@@ -35,7 +35,7 @@ | |||
35 | }; | 35 | }; |
36 | }; | 36 | }; |
37 | 37 | ||
38 | memory@20000000 { | 38 | memory { |
39 | reg = <0x20000000 0x08000000>; | 39 | reg = <0x20000000 0x08000000>; |
40 | }; | 40 | }; |
41 | 41 | ||
diff --git a/arch/arm/boot/dts/at91sam9g25ek.dts b/arch/arm/boot/dts/at91sam9g25ek.dts index ac0dc0031dda..7829a4d0cb22 100644 --- a/arch/arm/boot/dts/at91sam9g25ek.dts +++ b/arch/arm/boot/dts/at91sam9g25ek.dts | |||
@@ -37,8 +37,8 @@ | |||
37 | usb0: ohci@00600000 { | 37 | usb0: ohci@00600000 { |
38 | status = "okay"; | 38 | status = "okay"; |
39 | num-ports = <2>; | 39 | num-ports = <2>; |
40 | atmel,vbus-gpio = <&pioD 19 0 | 40 | atmel,vbus-gpio = <&pioD 19 1 |
41 | &pioD 20 0 | 41 | &pioD 20 1 |
42 | >; | 42 | >; |
43 | }; | 43 | }; |
44 | 44 | ||
diff --git a/arch/arm/boot/dts/at91sam9g45.dtsi b/arch/arm/boot/dts/at91sam9g45.dtsi index 3d0c32fb218f..9e6eb6ecea0e 100644 --- a/arch/arm/boot/dts/at91sam9g45.dtsi +++ b/arch/arm/boot/dts/at91sam9g45.dtsi | |||
@@ -36,7 +36,7 @@ | |||
36 | }; | 36 | }; |
37 | }; | 37 | }; |
38 | 38 | ||
39 | memory@70000000 { | 39 | memory { |
40 | reg = <0x70000000 0x10000000>; | 40 | reg = <0x70000000 0x10000000>; |
41 | }; | 41 | }; |
42 | 42 | ||
diff --git a/arch/arm/boot/dts/at91sam9m10g45ek.dts b/arch/arm/boot/dts/at91sam9m10g45ek.dts index c4c8ae4123d5..a3633bd13111 100644 --- a/arch/arm/boot/dts/at91sam9m10g45ek.dts +++ b/arch/arm/boot/dts/at91sam9m10g45ek.dts | |||
@@ -17,7 +17,7 @@ | |||
17 | bootargs = "mem=64M console=ttyS0,115200 root=/dev/mtdblock1 rw rootfstype=jffs2"; | 17 | bootargs = "mem=64M console=ttyS0,115200 root=/dev/mtdblock1 rw rootfstype=jffs2"; |
18 | }; | 18 | }; |
19 | 19 | ||
20 | memory@70000000 { | 20 | memory { |
21 | reg = <0x70000000 0x4000000>; | 21 | reg = <0x70000000 0x4000000>; |
22 | }; | 22 | }; |
23 | 23 | ||
@@ -73,8 +73,8 @@ | |||
73 | usb0: ohci@00700000 { | 73 | usb0: ohci@00700000 { |
74 | status = "okay"; | 74 | status = "okay"; |
75 | num-ports = <2>; | 75 | num-ports = <2>; |
76 | atmel,vbus-gpio = <&pioD 1 0 | 76 | atmel,vbus-gpio = <&pioD 1 1 |
77 | &pioD 3 0>; | 77 | &pioD 3 1>; |
78 | }; | 78 | }; |
79 | 79 | ||
80 | usb1: ehci@00800000 { | 80 | usb1: ehci@00800000 { |
diff --git a/arch/arm/boot/dts/at91sam9x5.dtsi b/arch/arm/boot/dts/at91sam9x5.dtsi index c111001f254e..70ab3a4e026f 100644 --- a/arch/arm/boot/dts/at91sam9x5.dtsi +++ b/arch/arm/boot/dts/at91sam9x5.dtsi | |||
@@ -34,7 +34,7 @@ | |||
34 | }; | 34 | }; |
35 | }; | 35 | }; |
36 | 36 | ||
37 | memory@20000000 { | 37 | memory { |
38 | reg = <0x20000000 0x10000000>; | 38 | reg = <0x20000000 0x10000000>; |
39 | }; | 39 | }; |
40 | 40 | ||
@@ -201,8 +201,8 @@ | |||
201 | >; | 201 | >; |
202 | atmel,nand-addr-offset = <21>; | 202 | atmel,nand-addr-offset = <21>; |
203 | atmel,nand-cmd-offset = <22>; | 203 | atmel,nand-cmd-offset = <22>; |
204 | gpios = <&pioC 8 0 | 204 | gpios = <&pioD 5 0 |
205 | &pioC 14 0 | 205 | &pioD 4 0 |
206 | 0 | 206 | 0 |
207 | >; | 207 | >; |
208 | status = "disabled"; | 208 | status = "disabled"; |
diff --git a/arch/arm/boot/dts/at91sam9x5cm.dtsi b/arch/arm/boot/dts/at91sam9x5cm.dtsi index 67936f83c694..31e7be23703d 100644 --- a/arch/arm/boot/dts/at91sam9x5cm.dtsi +++ b/arch/arm/boot/dts/at91sam9x5cm.dtsi | |||
@@ -8,7 +8,7 @@ | |||
8 | */ | 8 | */ |
9 | 9 | ||
10 | / { | 10 | / { |
11 | memory@20000000 { | 11 | memory { |
12 | reg = <0x20000000 0x8000000>; | 12 | reg = <0x20000000 0x8000000>; |
13 | }; | 13 | }; |
14 | 14 | ||
diff --git a/arch/arm/boot/dts/usb_a9g20.dts b/arch/arm/boot/dts/usb_a9g20.dts index 3b3c4e0fa79f..7c2399c532e5 100644 --- a/arch/arm/boot/dts/usb_a9g20.dts +++ b/arch/arm/boot/dts/usb_a9g20.dts | |||
@@ -16,7 +16,7 @@ | |||
16 | bootargs = "mem=64M console=ttyS0,115200 root=/dev/mtdblock5 rw rootfstype=ubifs"; | 16 | bootargs = "mem=64M console=ttyS0,115200 root=/dev/mtdblock5 rw rootfstype=ubifs"; |
17 | }; | 17 | }; |
18 | 18 | ||
19 | memory@20000000 { | 19 | memory { |
20 | reg = <0x20000000 0x4000000>; | 20 | reg = <0x20000000 0x4000000>; |
21 | }; | 21 | }; |
22 | 22 | ||
diff --git a/arch/arm/mach-at91/at91sam9260_devices.c b/arch/arm/mach-at91/at91sam9260_devices.c index 7e5651ee9f85..5652dde4bbe2 100644 --- a/arch/arm/mach-at91/at91sam9260_devices.c +++ b/arch/arm/mach-at91/at91sam9260_devices.c | |||
@@ -598,6 +598,9 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) | |||
598 | else | 598 | else |
599 | cs_pin = spi1_standard_cs[devices[i].chip_select]; | 599 | cs_pin = spi1_standard_cs[devices[i].chip_select]; |
600 | 600 | ||
601 | if (!gpio_is_valid(cs_pin)) | ||
602 | continue; | ||
603 | |||
601 | if (devices[i].bus_num == 0) | 604 | if (devices[i].bus_num == 0) |
602 | enable_spi0 = 1; | 605 | enable_spi0 = 1; |
603 | else | 606 | else |
diff --git a/arch/arm/mach-at91/at91sam9261_devices.c b/arch/arm/mach-at91/at91sam9261_devices.c index 096da87dc00d..4db961a93085 100644 --- a/arch/arm/mach-at91/at91sam9261_devices.c +++ b/arch/arm/mach-at91/at91sam9261_devices.c | |||
@@ -415,6 +415,9 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) | |||
415 | else | 415 | else |
416 | cs_pin = spi1_standard_cs[devices[i].chip_select]; | 416 | cs_pin = spi1_standard_cs[devices[i].chip_select]; |
417 | 417 | ||
418 | if (!gpio_is_valid(cs_pin)) | ||
419 | continue; | ||
420 | |||
418 | if (devices[i].bus_num == 0) | 421 | if (devices[i].bus_num == 0) |
419 | enable_spi0 = 1; | 422 | enable_spi0 = 1; |
420 | else | 423 | else |
diff --git a/arch/arm/mach-at91/at91sam9263_devices.c b/arch/arm/mach-at91/at91sam9263_devices.c index 53688c46f956..fe99206de880 100644 --- a/arch/arm/mach-at91/at91sam9263_devices.c +++ b/arch/arm/mach-at91/at91sam9263_devices.c | |||
@@ -72,7 +72,8 @@ void __init at91_add_device_usbh(struct at91_usbh_data *data) | |||
72 | /* Enable VBus control for UHP ports */ | 72 | /* Enable VBus control for UHP ports */ |
73 | for (i = 0; i < data->ports; i++) { | 73 | for (i = 0; i < data->ports; i++) { |
74 | if (gpio_is_valid(data->vbus_pin[i])) | 74 | if (gpio_is_valid(data->vbus_pin[i])) |
75 | at91_set_gpio_output(data->vbus_pin[i], 0); | 75 | at91_set_gpio_output(data->vbus_pin[i], |
76 | data->vbus_pin_active_low[i]); | ||
76 | } | 77 | } |
77 | 78 | ||
78 | /* Enable overcurrent notification */ | 79 | /* Enable overcurrent notification */ |
@@ -671,6 +672,9 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) | |||
671 | else | 672 | else |
672 | cs_pin = spi1_standard_cs[devices[i].chip_select]; | 673 | cs_pin = spi1_standard_cs[devices[i].chip_select]; |
673 | 674 | ||
675 | if (!gpio_is_valid(cs_pin)) | ||
676 | continue; | ||
677 | |||
674 | if (devices[i].bus_num == 0) | 678 | if (devices[i].bus_num == 0) |
675 | enable_spi0 = 1; | 679 | enable_spi0 = 1; |
676 | else | 680 | else |
diff --git a/arch/arm/mach-at91/at91sam9g45_devices.c b/arch/arm/mach-at91/at91sam9g45_devices.c index 698479f1e197..6b008aee1dff 100644 --- a/arch/arm/mach-at91/at91sam9g45_devices.c +++ b/arch/arm/mach-at91/at91sam9g45_devices.c | |||
@@ -127,12 +127,13 @@ void __init at91_add_device_usbh_ohci(struct at91_usbh_data *data) | |||
127 | /* Enable VBus control for UHP ports */ | 127 | /* Enable VBus control for UHP ports */ |
128 | for (i = 0; i < data->ports; i++) { | 128 | for (i = 0; i < data->ports; i++) { |
129 | if (gpio_is_valid(data->vbus_pin[i])) | 129 | if (gpio_is_valid(data->vbus_pin[i])) |
130 | at91_set_gpio_output(data->vbus_pin[i], 0); | 130 | at91_set_gpio_output(data->vbus_pin[i], |
131 | data->vbus_pin_active_low[i]); | ||
131 | } | 132 | } |
132 | 133 | ||
133 | /* Enable overcurrent notification */ | 134 | /* Enable overcurrent notification */ |
134 | for (i = 0; i < data->ports; i++) { | 135 | for (i = 0; i < data->ports; i++) { |
135 | if (data->overcurrent_pin[i]) | 136 | if (gpio_is_valid(data->overcurrent_pin[i])) |
136 | at91_set_gpio_input(data->overcurrent_pin[i], 1); | 137 | at91_set_gpio_input(data->overcurrent_pin[i], 1); |
137 | } | 138 | } |
138 | 139 | ||
@@ -188,7 +189,8 @@ void __init at91_add_device_usbh_ehci(struct at91_usbh_data *data) | |||
188 | /* Enable VBus control for UHP ports */ | 189 | /* Enable VBus control for UHP ports */ |
189 | for (i = 0; i < data->ports; i++) { | 190 | for (i = 0; i < data->ports; i++) { |
190 | if (gpio_is_valid(data->vbus_pin[i])) | 191 | if (gpio_is_valid(data->vbus_pin[i])) |
191 | at91_set_gpio_output(data->vbus_pin[i], 0); | 192 | at91_set_gpio_output(data->vbus_pin[i], |
193 | data->vbus_pin_active_low[i]); | ||
192 | } | 194 | } |
193 | 195 | ||
194 | usbh_ehci_data = *data; | 196 | usbh_ehci_data = *data; |
@@ -785,6 +787,9 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) | |||
785 | else | 787 | else |
786 | cs_pin = spi1_standard_cs[devices[i].chip_select]; | 788 | cs_pin = spi1_standard_cs[devices[i].chip_select]; |
787 | 789 | ||
790 | if (!gpio_is_valid(cs_pin)) | ||
791 | continue; | ||
792 | |||
788 | if (devices[i].bus_num == 0) | 793 | if (devices[i].bus_num == 0) |
789 | enable_spi0 = 1; | 794 | enable_spi0 = 1; |
790 | else | 795 | else |
diff --git a/arch/arm/mach-at91/at91sam9rl_devices.c b/arch/arm/mach-at91/at91sam9rl_devices.c index eda72e83037d..fe4ae22e8561 100644 --- a/arch/arm/mach-at91/at91sam9rl_devices.c +++ b/arch/arm/mach-at91/at91sam9rl_devices.c | |||
@@ -419,6 +419,9 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) | |||
419 | else | 419 | else |
420 | cs_pin = spi_standard_cs[devices[i].chip_select]; | 420 | cs_pin = spi_standard_cs[devices[i].chip_select]; |
421 | 421 | ||
422 | if (!gpio_is_valid(cs_pin)) | ||
423 | continue; | ||
424 | |||
422 | /* enable chip-select pin */ | 425 | /* enable chip-select pin */ |
423 | at91_set_gpio_output(cs_pin, 1); | 426 | at91_set_gpio_output(cs_pin, 1); |
424 | 427 | ||
diff --git a/arch/arm/mach-at91/at91sam9x5.c b/arch/arm/mach-at91/at91sam9x5.c index b6831eeb7b76..13c8cae60462 100644 --- a/arch/arm/mach-at91/at91sam9x5.c +++ b/arch/arm/mach-at91/at91sam9x5.c | |||
@@ -223,6 +223,8 @@ static struct clk_lookup periph_clocks_lookups[] = { | |||
223 | CLKDEV_CON_DEV_ID("usart", "f8028000.serial", &usart3_clk), | 223 | CLKDEV_CON_DEV_ID("usart", "f8028000.serial", &usart3_clk), |
224 | CLKDEV_CON_DEV_ID("t0_clk", "f8008000.timer", &tcb0_clk), | 224 | CLKDEV_CON_DEV_ID("t0_clk", "f8008000.timer", &tcb0_clk), |
225 | CLKDEV_CON_DEV_ID("t0_clk", "f800c000.timer", &tcb0_clk), | 225 | CLKDEV_CON_DEV_ID("t0_clk", "f800c000.timer", &tcb0_clk), |
226 | CLKDEV_CON_DEV_ID("dma_clk", "ffffec00.dma-controller", &dma0_clk), | ||
227 | CLKDEV_CON_DEV_ID("dma_clk", "ffffee00.dma-controller", &dma1_clk), | ||
226 | CLKDEV_CON_ID("pioA", &pioAB_clk), | 228 | CLKDEV_CON_ID("pioA", &pioAB_clk), |
227 | CLKDEV_CON_ID("pioB", &pioAB_clk), | 229 | CLKDEV_CON_ID("pioB", &pioAB_clk), |
228 | CLKDEV_CON_ID("pioC", &pioCD_clk), | 230 | CLKDEV_CON_ID("pioC", &pioCD_clk), |
diff --git a/arch/arm/mach-at91/board-sam9263ek.c b/arch/arm/mach-at91/board-sam9263ek.c index 66f0ddf4b2ae..2ffe50f3a9e9 100644 --- a/arch/arm/mach-at91/board-sam9263ek.c +++ b/arch/arm/mach-at91/board-sam9263ek.c | |||
@@ -74,6 +74,7 @@ static void __init ek_init_early(void) | |||
74 | static struct at91_usbh_data __initdata ek_usbh_data = { | 74 | static struct at91_usbh_data __initdata ek_usbh_data = { |
75 | .ports = 2, | 75 | .ports = 2, |
76 | .vbus_pin = { AT91_PIN_PA24, AT91_PIN_PA21 }, | 76 | .vbus_pin = { AT91_PIN_PA24, AT91_PIN_PA21 }, |
77 | .vbus_pin_active_low = {1, 1}, | ||
77 | .overcurrent_pin= {-EINVAL, -EINVAL}, | 78 | .overcurrent_pin= {-EINVAL, -EINVAL}, |
78 | }; | 79 | }; |
79 | 80 | ||
diff --git a/arch/arm/mach-at91/board-sam9m10g45ek.c b/arch/arm/mach-at91/board-sam9m10g45ek.c index e1bea73e6b30..c88e908ddd82 100644 --- a/arch/arm/mach-at91/board-sam9m10g45ek.c +++ b/arch/arm/mach-at91/board-sam9m10g45ek.c | |||
@@ -71,6 +71,7 @@ static void __init ek_init_early(void) | |||
71 | static struct at91_usbh_data __initdata ek_usbh_hs_data = { | 71 | static struct at91_usbh_data __initdata ek_usbh_hs_data = { |
72 | .ports = 2, | 72 | .ports = 2, |
73 | .vbus_pin = {AT91_PIN_PD1, AT91_PIN_PD3}, | 73 | .vbus_pin = {AT91_PIN_PD1, AT91_PIN_PD3}, |
74 | .vbus_pin_active_low = {1, 1}, | ||
74 | .overcurrent_pin= {-EINVAL, -EINVAL}, | 75 | .overcurrent_pin= {-EINVAL, -EINVAL}, |
75 | }; | 76 | }; |
76 | 77 | ||
diff --git a/arch/arm/mach-at91/include/mach/board.h b/arch/arm/mach-at91/include/mach/board.h index 544a5d5ce416..49a821192c65 100644 --- a/arch/arm/mach-at91/include/mach/board.h +++ b/arch/arm/mach-at91/include/mach/board.h | |||
@@ -86,14 +86,15 @@ extern void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *d | |||
86 | extern void __init at91_add_device_eth(struct macb_platform_data *data); | 86 | extern void __init at91_add_device_eth(struct macb_platform_data *data); |
87 | 87 | ||
88 | /* USB Host */ | 88 | /* USB Host */ |
89 | #define AT91_MAX_USBH_PORTS 3 | ||
89 | struct at91_usbh_data { | 90 | struct at91_usbh_data { |
90 | u8 ports; /* number of ports on root hub */ | 91 | int vbus_pin[AT91_MAX_USBH_PORTS]; /* port power-control pin */ |
91 | int vbus_pin[2]; /* port power-control pin */ | 92 | int overcurrent_pin[AT91_MAX_USBH_PORTS]; |
92 | u8 vbus_pin_active_low[2]; | 93 | u8 ports; /* number of ports on root hub */ |
93 | u8 overcurrent_supported; | 94 | u8 overcurrent_supported; |
94 | int overcurrent_pin[2]; | 95 | u8 vbus_pin_active_low[AT91_MAX_USBH_PORTS]; |
95 | u8 overcurrent_status[2]; | 96 | u8 overcurrent_status[AT91_MAX_USBH_PORTS]; |
96 | u8 overcurrent_changed[2]; | 97 | u8 overcurrent_changed[AT91_MAX_USBH_PORTS]; |
97 | }; | 98 | }; |
98 | extern void __init at91_add_device_usbh(struct at91_usbh_data *data); | 99 | extern void __init at91_add_device_usbh(struct at91_usbh_data *data); |
99 | extern void __init at91_add_device_usbh_ohci(struct at91_usbh_data *data); | 100 | extern void __init at91_add_device_usbh_ohci(struct at91_usbh_data *data); |
diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c index 19f318ababa2..cf14c95a6700 100644 --- a/drivers/usb/host/ehci-atmel.c +++ b/drivers/usb/host/ehci-atmel.c | |||
@@ -13,6 +13,7 @@ | |||
13 | 13 | ||
14 | #include <linux/clk.h> | 14 | #include <linux/clk.h> |
15 | #include <linux/platform_device.h> | 15 | #include <linux/platform_device.h> |
16 | #include <linux/of.h> | ||
16 | #include <linux/of_platform.h> | 17 | #include <linux/of_platform.h> |
17 | 18 | ||
18 | /* interface and function clocks */ | 19 | /* interface and function clocks */ |
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c index db8963f5fbce..09f597ad6e00 100644 --- a/drivers/usb/host/ohci-at91.c +++ b/drivers/usb/host/ohci-at91.c | |||
@@ -27,6 +27,10 @@ | |||
27 | #error "CONFIG_ARCH_AT91 must be defined." | 27 | #error "CONFIG_ARCH_AT91 must be defined." |
28 | #endif | 28 | #endif |
29 | 29 | ||
30 | #define valid_port(index) ((index) >= 0 && (index) < AT91_MAX_USBH_PORTS) | ||
31 | #define at91_for_each_port(index) \ | ||
32 | for ((index) = 0; (index) < AT91_MAX_USBH_PORTS; (index)++) | ||
33 | |||
30 | /* interface and function clocks; sometimes also an AHB clock */ | 34 | /* interface and function clocks; sometimes also an AHB clock */ |
31 | static struct clk *iclk, *fclk, *hclk; | 35 | static struct clk *iclk, *fclk, *hclk; |
32 | static int clocked; | 36 | static int clocked; |
@@ -240,26 +244,26 @@ ohci_at91_start (struct usb_hcd *hcd) | |||
240 | 244 | ||
241 | static void ohci_at91_usb_set_power(struct at91_usbh_data *pdata, int port, int enable) | 245 | static void ohci_at91_usb_set_power(struct at91_usbh_data *pdata, int port, int enable) |
242 | { | 246 | { |
243 | if (port < 0 || port >= 2) | 247 | if (!valid_port(port)) |
244 | return; | 248 | return; |
245 | 249 | ||
246 | if (!gpio_is_valid(pdata->vbus_pin[port])) | 250 | if (!gpio_is_valid(pdata->vbus_pin[port])) |
247 | return; | 251 | return; |
248 | 252 | ||
249 | gpio_set_value(pdata->vbus_pin[port], | 253 | gpio_set_value(pdata->vbus_pin[port], |
250 | !pdata->vbus_pin_active_low[port] ^ enable); | 254 | pdata->vbus_pin_active_low[port] ^ enable); |
251 | } | 255 | } |
252 | 256 | ||
253 | static int ohci_at91_usb_get_power(struct at91_usbh_data *pdata, int port) | 257 | static int ohci_at91_usb_get_power(struct at91_usbh_data *pdata, int port) |
254 | { | 258 | { |
255 | if (port < 0 || port >= 2) | 259 | if (!valid_port(port)) |
256 | return -EINVAL; | 260 | return -EINVAL; |
257 | 261 | ||
258 | if (!gpio_is_valid(pdata->vbus_pin[port])) | 262 | if (!gpio_is_valid(pdata->vbus_pin[port])) |
259 | return -EINVAL; | 263 | return -EINVAL; |
260 | 264 | ||
261 | return gpio_get_value(pdata->vbus_pin[port]) ^ | 265 | return gpio_get_value(pdata->vbus_pin[port]) ^ |
262 | !pdata->vbus_pin_active_low[port]; | 266 | pdata->vbus_pin_active_low[port]; |
263 | } | 267 | } |
264 | 268 | ||
265 | /* | 269 | /* |
@@ -271,9 +275,9 @@ static int ohci_at91_hub_status_data(struct usb_hcd *hcd, char *buf) | |||
271 | int length = ohci_hub_status_data(hcd, buf); | 275 | int length = ohci_hub_status_data(hcd, buf); |
272 | int port; | 276 | int port; |
273 | 277 | ||
274 | for (port = 0; port < ARRAY_SIZE(pdata->overcurrent_pin); port++) { | 278 | at91_for_each_port(port) { |
275 | if (pdata->overcurrent_changed[port]) { | 279 | if (pdata->overcurrent_changed[port]) { |
276 | if (! length) | 280 | if (!length) |
277 | length = 1; | 281 | length = 1; |
278 | buf[0] |= 1 << (port + 1); | 282 | buf[0] |= 1 << (port + 1); |
279 | } | 283 | } |
@@ -297,11 +301,17 @@ static int ohci_at91_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, | |||
297 | "ohci_at91_hub_control(%p,0x%04x,0x%04x,0x%04x,%p,%04x)\n", | 301 | "ohci_at91_hub_control(%p,0x%04x,0x%04x,0x%04x,%p,%04x)\n", |
298 | hcd, typeReq, wValue, wIndex, buf, wLength); | 302 | hcd, typeReq, wValue, wIndex, buf, wLength); |
299 | 303 | ||
304 | wIndex--; | ||
305 | |||
300 | switch (typeReq) { | 306 | switch (typeReq) { |
301 | case SetPortFeature: | 307 | case SetPortFeature: |
302 | if (wValue == USB_PORT_FEAT_POWER) { | 308 | if (wValue == USB_PORT_FEAT_POWER) { |
303 | dev_dbg(hcd->self.controller, "SetPortFeat: POWER\n"); | 309 | dev_dbg(hcd->self.controller, "SetPortFeat: POWER\n"); |
304 | ohci_at91_usb_set_power(pdata, wIndex - 1, 1); | 310 | if (valid_port(wIndex)) { |
311 | ohci_at91_usb_set_power(pdata, wIndex, 1); | ||
312 | ret = 0; | ||
313 | } | ||
314 | |||
305 | goto out; | 315 | goto out; |
306 | } | 316 | } |
307 | break; | 317 | break; |
@@ -312,9 +322,9 @@ static int ohci_at91_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, | |||
312 | dev_dbg(hcd->self.controller, | 322 | dev_dbg(hcd->self.controller, |
313 | "ClearPortFeature: C_OVER_CURRENT\n"); | 323 | "ClearPortFeature: C_OVER_CURRENT\n"); |
314 | 324 | ||
315 | if (wIndex == 1 || wIndex == 2) { | 325 | if (valid_port(wIndex)) { |
316 | pdata->overcurrent_changed[wIndex-1] = 0; | 326 | pdata->overcurrent_changed[wIndex] = 0; |
317 | pdata->overcurrent_status[wIndex-1] = 0; | 327 | pdata->overcurrent_status[wIndex] = 0; |
318 | } | 328 | } |
319 | 329 | ||
320 | goto out; | 330 | goto out; |
@@ -323,9 +333,8 @@ static int ohci_at91_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, | |||
323 | dev_dbg(hcd->self.controller, | 333 | dev_dbg(hcd->self.controller, |
324 | "ClearPortFeature: OVER_CURRENT\n"); | 334 | "ClearPortFeature: OVER_CURRENT\n"); |
325 | 335 | ||
326 | if (wIndex == 1 || wIndex == 2) { | 336 | if (valid_port(wIndex)) |
327 | pdata->overcurrent_status[wIndex-1] = 0; | 337 | pdata->overcurrent_status[wIndex] = 0; |
328 | } | ||
329 | 338 | ||
330 | goto out; | 339 | goto out; |
331 | 340 | ||
@@ -333,15 +342,15 @@ static int ohci_at91_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, | |||
333 | dev_dbg(hcd->self.controller, | 342 | dev_dbg(hcd->self.controller, |
334 | "ClearPortFeature: POWER\n"); | 343 | "ClearPortFeature: POWER\n"); |
335 | 344 | ||
336 | if (wIndex == 1 || wIndex == 2) { | 345 | if (valid_port(wIndex)) { |
337 | ohci_at91_usb_set_power(pdata, wIndex - 1, 0); | 346 | ohci_at91_usb_set_power(pdata, wIndex, 0); |
338 | return 0; | 347 | return 0; |
339 | } | 348 | } |
340 | } | 349 | } |
341 | break; | 350 | break; |
342 | } | 351 | } |
343 | 352 | ||
344 | ret = ohci_hub_control(hcd, typeReq, wValue, wIndex, buf, wLength); | 353 | ret = ohci_hub_control(hcd, typeReq, wValue, wIndex + 1, buf, wLength); |
345 | if (ret) | 354 | if (ret) |
346 | goto out; | 355 | goto out; |
347 | 356 | ||
@@ -377,18 +386,15 @@ static int ohci_at91_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, | |||
377 | 386 | ||
378 | dev_dbg(hcd->self.controller, "GetPortStatus(%d)\n", wIndex); | 387 | dev_dbg(hcd->self.controller, "GetPortStatus(%d)\n", wIndex); |
379 | 388 | ||
380 | if (wIndex == 1 || wIndex == 2) { | 389 | if (valid_port(wIndex)) { |
381 | if (! ohci_at91_usb_get_power(pdata, wIndex-1)) { | 390 | if (!ohci_at91_usb_get_power(pdata, wIndex)) |
382 | *data &= ~cpu_to_le32(RH_PS_PPS); | 391 | *data &= ~cpu_to_le32(RH_PS_PPS); |
383 | } | ||
384 | 392 | ||
385 | if (pdata->overcurrent_changed[wIndex-1]) { | 393 | if (pdata->overcurrent_changed[wIndex]) |
386 | *data |= cpu_to_le32(RH_PS_OCIC); | 394 | *data |= cpu_to_le32(RH_PS_OCIC); |
387 | } | ||
388 | 395 | ||
389 | if (pdata->overcurrent_status[wIndex-1]) { | 396 | if (pdata->overcurrent_status[wIndex]) |
390 | *data |= cpu_to_le32(RH_PS_POCI); | 397 | *data |= cpu_to_le32(RH_PS_POCI); |
391 | } | ||
392 | } | 398 | } |
393 | } | 399 | } |
394 | 400 | ||
@@ -450,14 +456,14 @@ static irqreturn_t ohci_hcd_at91_overcurrent_irq(int irq, void *data) | |||
450 | 456 | ||
451 | /* From the GPIO notifying the over-current situation, find | 457 | /* From the GPIO notifying the over-current situation, find |
452 | * out the corresponding port */ | 458 | * out the corresponding port */ |
453 | for (port = 0; port < ARRAY_SIZE(pdata->overcurrent_pin); port++) { | 459 | at91_for_each_port(port) { |
454 | if (gpio_to_irq(pdata->overcurrent_pin[port]) == irq) { | 460 | if (gpio_to_irq(pdata->overcurrent_pin[port]) == irq) { |
455 | gpio = pdata->overcurrent_pin[port]; | 461 | gpio = pdata->overcurrent_pin[port]; |
456 | break; | 462 | break; |
457 | } | 463 | } |
458 | } | 464 | } |
459 | 465 | ||
460 | if (port == ARRAY_SIZE(pdata->overcurrent_pin)) { | 466 | if (port == AT91_MAX_USBH_PORTS) { |
461 | dev_err(& pdev->dev, "overcurrent interrupt from unknown GPIO\n"); | 467 | dev_err(& pdev->dev, "overcurrent interrupt from unknown GPIO\n"); |
462 | return IRQ_HANDLED; | 468 | return IRQ_HANDLED; |
463 | } | 469 | } |
@@ -467,7 +473,7 @@ static irqreturn_t ohci_hcd_at91_overcurrent_irq(int irq, void *data) | |||
467 | /* When notified of an over-current situation, disable power | 473 | /* When notified of an over-current situation, disable power |
468 | on the corresponding port, and mark this port in | 474 | on the corresponding port, and mark this port in |
469 | over-current. */ | 475 | over-current. */ |
470 | if (! val) { | 476 | if (!val) { |
471 | ohci_at91_usb_set_power(pdata, port, 0); | 477 | ohci_at91_usb_set_power(pdata, port, 0); |
472 | pdata->overcurrent_status[port] = 1; | 478 | pdata->overcurrent_status[port] = 1; |
473 | pdata->overcurrent_changed[port] = 1; | 479 | pdata->overcurrent_changed[port] = 1; |
@@ -492,7 +498,7 @@ static u64 at91_ohci_dma_mask = DMA_BIT_MASK(32); | |||
492 | static int __devinit ohci_at91_of_init(struct platform_device *pdev) | 498 | static int __devinit ohci_at91_of_init(struct platform_device *pdev) |
493 | { | 499 | { |
494 | struct device_node *np = pdev->dev.of_node; | 500 | struct device_node *np = pdev->dev.of_node; |
495 | int i, ret, gpio; | 501 | int i, gpio; |
496 | enum of_gpio_flags flags; | 502 | enum of_gpio_flags flags; |
497 | struct at91_usbh_data *pdata; | 503 | struct at91_usbh_data *pdata; |
498 | u32 ports; | 504 | u32 ports; |
@@ -514,48 +520,17 @@ static int __devinit ohci_at91_of_init(struct platform_device *pdev) | |||
514 | if (!of_property_read_u32(np, "num-ports", &ports)) | 520 | if (!of_property_read_u32(np, "num-ports", &ports)) |
515 | pdata->ports = ports; | 521 | pdata->ports = ports; |
516 | 522 | ||
517 | for (i = 0; i < 2; i++) { | 523 | at91_for_each_port(i) { |
518 | gpio = of_get_named_gpio_flags(np, "atmel,vbus-gpio", i, &flags); | 524 | gpio = of_get_named_gpio_flags(np, "atmel,vbus-gpio", i, &flags); |
519 | pdata->vbus_pin[i] = gpio; | 525 | pdata->vbus_pin[i] = gpio; |
520 | if (!gpio_is_valid(gpio)) | 526 | if (!gpio_is_valid(gpio)) |
521 | continue; | 527 | continue; |
522 | pdata->vbus_pin_active_low[i] = flags & OF_GPIO_ACTIVE_LOW; | 528 | pdata->vbus_pin_active_low[i] = flags & OF_GPIO_ACTIVE_LOW; |
523 | ret = gpio_request(gpio, "ohci_vbus"); | ||
524 | if (ret) { | ||
525 | dev_warn(&pdev->dev, "can't request vbus gpio %d", gpio); | ||
526 | continue; | ||
527 | } | ||
528 | ret = gpio_direction_output(gpio, !(flags & OF_GPIO_ACTIVE_LOW) ^ 1); | ||
529 | if (ret) | ||
530 | dev_warn(&pdev->dev, "can't put vbus gpio %d as output %d", | ||
531 | !(flags & OF_GPIO_ACTIVE_LOW) ^ 1, gpio); | ||
532 | } | 529 | } |
533 | 530 | ||
534 | for (i = 0; i < 2; i++) { | 531 | at91_for_each_port(i) |
535 | gpio = of_get_named_gpio_flags(np, "atmel,oc-gpio", i, &flags); | 532 | pdata->overcurrent_pin[i] = |
536 | pdata->overcurrent_pin[i] = gpio; | 533 | of_get_named_gpio_flags(np, "atmel,oc-gpio", i, &flags); |
537 | if (!gpio_is_valid(gpio)) | ||
538 | continue; | ||
539 | ret = gpio_request(gpio, "ohci_overcurrent"); | ||
540 | if (ret) { | ||
541 | dev_err(&pdev->dev, "can't request overcurrent gpio %d", gpio); | ||
542 | continue; | ||
543 | } | ||
544 | |||
545 | ret = gpio_direction_input(gpio); | ||
546 | if (ret) { | ||
547 | dev_err(&pdev->dev, "can't configure overcurrent gpio %d as input", gpio); | ||
548 | continue; | ||
549 | } | ||
550 | |||
551 | ret = request_irq(gpio_to_irq(gpio), | ||
552 | ohci_hcd_at91_overcurrent_irq, | ||
553 | IRQF_SHARED, "ohci_overcurrent", pdev); | ||
554 | if (ret) { | ||
555 | gpio_free(gpio); | ||
556 | dev_warn(& pdev->dev, "cannot get GPIO IRQ for overcurrent\n"); | ||
557 | } | ||
558 | } | ||
559 | 534 | ||
560 | pdev->dev.platform_data = pdata; | 535 | pdev->dev.platform_data = pdata; |
561 | 536 | ||
@@ -574,35 +549,69 @@ static int ohci_hcd_at91_drv_probe(struct platform_device *pdev) | |||
574 | { | 549 | { |
575 | struct at91_usbh_data *pdata; | 550 | struct at91_usbh_data *pdata; |
576 | int i; | 551 | int i; |
552 | int gpio; | ||
553 | int ret; | ||
577 | 554 | ||
578 | i = ohci_at91_of_init(pdev); | 555 | ret = ohci_at91_of_init(pdev); |
579 | 556 | if (ret) | |
580 | if (i) | 557 | return ret; |
581 | return i; | ||
582 | 558 | ||
583 | pdata = pdev->dev.platform_data; | 559 | pdata = pdev->dev.platform_data; |
584 | 560 | ||
585 | if (pdata) { | 561 | if (pdata) { |
586 | for (i = 0; i < ARRAY_SIZE(pdata->vbus_pin); i++) { | 562 | at91_for_each_port(i) { |
587 | if (!gpio_is_valid(pdata->vbus_pin[i])) | 563 | if (!gpio_is_valid(pdata->vbus_pin[i])) |
588 | continue; | 564 | continue; |
589 | gpio_request(pdata->vbus_pin[i], "ohci_vbus"); | 565 | gpio = pdata->vbus_pin[i]; |
566 | |||
567 | ret = gpio_request(gpio, "ohci_vbus"); | ||
568 | if (ret) { | ||
569 | dev_err(&pdev->dev, | ||
570 | "can't request vbus gpio %d\n", gpio); | ||
571 | continue; | ||
572 | } | ||
573 | ret = gpio_direction_output(gpio, | ||
574 | !pdata->vbus_pin_active_low[i]); | ||
575 | if (ret) { | ||
576 | dev_err(&pdev->dev, | ||
577 | "can't put vbus gpio %d as output %d\n", | ||
578 | gpio, !pdata->vbus_pin_active_low[i]); | ||
579 | gpio_free(gpio); | ||
580 | continue; | ||
581 | } | ||
582 | |||
590 | ohci_at91_usb_set_power(pdata, i, 1); | 583 | ohci_at91_usb_set_power(pdata, i, 1); |
591 | } | 584 | } |
592 | 585 | ||
593 | for (i = 0; i < ARRAY_SIZE(pdata->overcurrent_pin); i++) { | 586 | at91_for_each_port(i) { |
594 | int ret; | ||
595 | |||
596 | if (!gpio_is_valid(pdata->overcurrent_pin[i])) | 587 | if (!gpio_is_valid(pdata->overcurrent_pin[i])) |
597 | continue; | 588 | continue; |
598 | gpio_request(pdata->overcurrent_pin[i], "ohci_overcurrent"); | 589 | gpio = pdata->overcurrent_pin[i]; |
590 | |||
591 | ret = gpio_request(gpio, "ohci_overcurrent"); | ||
592 | if (ret) { | ||
593 | dev_err(&pdev->dev, | ||
594 | "can't request overcurrent gpio %d\n", | ||
595 | gpio); | ||
596 | continue; | ||
597 | } | ||
598 | |||
599 | ret = gpio_direction_input(gpio); | ||
600 | if (ret) { | ||
601 | dev_err(&pdev->dev, | ||
602 | "can't configure overcurrent gpio %d as input\n", | ||
603 | gpio); | ||
604 | gpio_free(gpio); | ||
605 | continue; | ||
606 | } | ||
599 | 607 | ||
600 | ret = request_irq(gpio_to_irq(pdata->overcurrent_pin[i]), | 608 | ret = request_irq(gpio_to_irq(gpio), |
601 | ohci_hcd_at91_overcurrent_irq, | 609 | ohci_hcd_at91_overcurrent_irq, |
602 | IRQF_SHARED, "ohci_overcurrent", pdev); | 610 | IRQF_SHARED, "ohci_overcurrent", pdev); |
603 | if (ret) { | 611 | if (ret) { |
604 | gpio_free(pdata->overcurrent_pin[i]); | 612 | gpio_free(gpio); |
605 | dev_warn(& pdev->dev, "cannot get GPIO IRQ for overcurrent\n"); | 613 | dev_err(&pdev->dev, |
614 | "can't get gpio IRQ for overcurrent\n"); | ||
606 | } | 615 | } |
607 | } | 616 | } |
608 | } | 617 | } |
@@ -617,14 +626,14 @@ static int ohci_hcd_at91_drv_remove(struct platform_device *pdev) | |||
617 | int i; | 626 | int i; |
618 | 627 | ||
619 | if (pdata) { | 628 | if (pdata) { |
620 | for (i = 0; i < ARRAY_SIZE(pdata->vbus_pin); i++) { | 629 | at91_for_each_port(i) { |
621 | if (!gpio_is_valid(pdata->vbus_pin[i])) | 630 | if (!gpio_is_valid(pdata->vbus_pin[i])) |
622 | continue; | 631 | continue; |
623 | ohci_at91_usb_set_power(pdata, i, 0); | 632 | ohci_at91_usb_set_power(pdata, i, 0); |
624 | gpio_free(pdata->vbus_pin[i]); | 633 | gpio_free(pdata->vbus_pin[i]); |
625 | } | 634 | } |
626 | 635 | ||
627 | for (i = 0; i < ARRAY_SIZE(pdata->overcurrent_pin); i++) { | 636 | at91_for_each_port(i) { |
628 | if (!gpio_is_valid(pdata->overcurrent_pin[i])) | 637 | if (!gpio_is_valid(pdata->overcurrent_pin[i])) |
629 | continue; | 638 | continue; |
630 | free_irq(gpio_to_irq(pdata->overcurrent_pin[i]), pdev); | 639 | free_irq(gpio_to_irq(pdata->overcurrent_pin[i]), pdev); |