diff options
| -rw-r--r-- | Documentation/devicetree/bindings/crypto/mv_cesa.txt | 20 | ||||
| -rw-r--r-- | Documentation/devicetree/bindings/gpio/gpio-fan.txt | 25 | ||||
| -rw-r--r-- | arch/arm/boot/dts/kirkwood-dnskw.dtsi | 10 | ||||
| -rw-r--r-- | arch/arm/boot/dts/kirkwood-iconnect.dts | 50 | ||||
| -rw-r--r-- | arch/arm/boot/dts/kirkwood.dtsi | 12 | ||||
| -rw-r--r-- | arch/arm/mach-kirkwood/board-dnskw.c | 26 | ||||
| -rw-r--r-- | arch/arm/mach-kirkwood/board-dt.c | 2 | ||||
| -rw-r--r-- | arch/arm/mach-kirkwood/board-iconnect.c | 48 | ||||
| -rw-r--r-- | drivers/crypto/mv_cesa.c | 17 | ||||
| -rw-r--r-- | drivers/hwmon/gpio-fan.c | 120 |
10 files changed, 251 insertions, 79 deletions
diff --git a/Documentation/devicetree/bindings/crypto/mv_cesa.txt b/Documentation/devicetree/bindings/crypto/mv_cesa.txt new file mode 100644 index 000000000000..47229b1a594b --- /dev/null +++ b/Documentation/devicetree/bindings/crypto/mv_cesa.txt | |||
| @@ -0,0 +1,20 @@ | |||
| 1 | Marvell Cryptographic Engines And Security Accelerator | ||
| 2 | |||
| 3 | Required properties: | ||
| 4 | - compatible : should be "marvell,orion-crypto" | ||
| 5 | - reg : base physical address of the engine and length of memory mapped | ||
| 6 | region, followed by base physical address of sram and its memory | ||
| 7 | length | ||
| 8 | - reg-names : "regs" , "sram"; | ||
| 9 | - interrupts : interrupt number | ||
| 10 | |||
| 11 | Examples: | ||
| 12 | |||
| 13 | crypto@30000 { | ||
| 14 | compatible = "marvell,orion-crypto"; | ||
| 15 | reg = <0x30000 0x10000>, | ||
| 16 | <0x4000000 0x800>; | ||
| 17 | reg-names = "regs" , "sram"; | ||
| 18 | interrupts = <22>; | ||
| 19 | status = "okay"; | ||
| 20 | }; | ||
diff --git a/Documentation/devicetree/bindings/gpio/gpio-fan.txt b/Documentation/devicetree/bindings/gpio/gpio-fan.txt new file mode 100644 index 000000000000..2dd457a3469a --- /dev/null +++ b/Documentation/devicetree/bindings/gpio/gpio-fan.txt | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | Bindings for fan connected to GPIO lines | ||
| 2 | |||
| 3 | Required properties: | ||
| 4 | - compatible : "gpio-fan" | ||
| 5 | - gpios: Specifies the pins that map to bits in the control value, | ||
| 6 | ordered MSB-->LSB. | ||
| 7 | - gpio-fan,speed-map: A mapping of possible fan RPM speeds and the | ||
| 8 | control value that should be set to achieve them. This array | ||
| 9 | must have the RPM values in ascending order. | ||
| 10 | |||
| 11 | Optional properties: | ||
| 12 | - alarm-gpios: This pin going active indicates something is wrong with | ||
| 13 | the fan, and a udev event will be fired. | ||
| 14 | |||
| 15 | Examples: | ||
| 16 | |||
| 17 | gpio_fan { | ||
| 18 | compatible = "gpio-fan"; | ||
| 19 | gpios = <&gpio1 14 1 | ||
| 20 | &gpio1 13 1>; | ||
| 21 | gpio-fan,speed-map = <0 0 | ||
| 22 | 3000 1 | ||
| 23 | 6000 2>; | ||
| 24 | alarm-gpios = <&gpio1 15 1>; | ||
| 25 | }; | ||
diff --git a/arch/arm/boot/dts/kirkwood-dnskw.dtsi b/arch/arm/boot/dts/kirkwood-dnskw.dtsi index 7408655f91b5..9b32d0272825 100644 --- a/arch/arm/boot/dts/kirkwood-dnskw.dtsi +++ b/arch/arm/boot/dts/kirkwood-dnskw.dtsi | |||
| @@ -25,6 +25,16 @@ | |||
| 25 | }; | 25 | }; |
| 26 | }; | 26 | }; |
| 27 | 27 | ||
| 28 | gpio_fan { | ||
| 29 | /* Fan: ADDA AD045HB-G73 40mm 6000rpm@5v */ | ||
| 30 | compatible = "gpio-fan"; | ||
| 31 | gpios = <&gpio1 14 1 | ||
| 32 | &gpio1 13 1>; | ||
| 33 | gpio-fan,speed-map = <0 0 | ||
| 34 | 3000 1 | ||
| 35 | 6000 2>; | ||
| 36 | }; | ||
| 37 | |||
| 28 | ocp@f1000000 { | 38 | ocp@f1000000 { |
| 29 | sata@80000 { | 39 | sata@80000 { |
| 30 | status = "okay"; | 40 | status = "okay"; |
diff --git a/arch/arm/boot/dts/kirkwood-iconnect.dts b/arch/arm/boot/dts/kirkwood-iconnect.dts index f8ca6fa88192..d97cd9d4753e 100644 --- a/arch/arm/boot/dts/kirkwood-iconnect.dts +++ b/arch/arm/boot/dts/kirkwood-iconnect.dts | |||
| @@ -12,7 +12,7 @@ | |||
| 12 | }; | 12 | }; |
| 13 | 13 | ||
| 14 | chosen { | 14 | chosen { |
| 15 | bootargs = "console=ttyS0,115200n8 earlyprintk mtdparts=orion_nand:0xc0000@0x0(uboot),0x20000@0xa0000(env),0x300000@0x100000(zImage),0x300000@0x540000(initrd),0x1f400000@0x980000(boot)"; | 15 | bootargs = "console=ttyS0,115200n8 earlyprintk"; |
| 16 | linux,initrd-start = <0x4500040>; | 16 | linux,initrd-start = <0x4500040>; |
| 17 | linux,initrd-end = <0x4800000>; | 17 | linux,initrd-end = <0x4800000>; |
| 18 | }; | 18 | }; |
| @@ -30,7 +30,37 @@ | |||
| 30 | clock-frequency = <200000000>; | 30 | clock-frequency = <200000000>; |
| 31 | status = "ok"; | 31 | status = "ok"; |
| 32 | }; | 32 | }; |
| 33 | |||
| 34 | nand@3000000 { | ||
| 35 | status = "okay"; | ||
| 36 | |||
| 37 | partition@0 { | ||
| 38 | label = "uboot"; | ||
| 39 | reg = <0x0000000 0xc0000>; | ||
| 40 | }; | ||
| 41 | |||
| 42 | partition@a0000 { | ||
| 43 | label = "env"; | ||
| 44 | reg = <0xa0000 0x20000>; | ||
| 45 | }; | ||
| 46 | |||
| 47 | partition@100000 { | ||
| 48 | label = "zImage"; | ||
| 49 | reg = <0x100000 0x300000>; | ||
| 50 | }; | ||
| 51 | |||
| 52 | partition@540000 { | ||
| 53 | label = "initrd"; | ||
| 54 | reg = <0x540000 0x300000>; | ||
| 55 | }; | ||
| 56 | |||
| 57 | partition@980000 { | ||
| 58 | label = "boot"; | ||
| 59 | reg = <0x980000 0x1f400000>; | ||
| 60 | }; | ||
| 61 | }; | ||
| 33 | }; | 62 | }; |
| 63 | |||
| 34 | gpio-leds { | 64 | gpio-leds { |
| 35 | compatible = "gpio-leds"; | 65 | compatible = "gpio-leds"; |
| 36 | 66 | ||
| @@ -69,4 +99,22 @@ | |||
| 69 | gpios = <&gpio1 16 0>; | 99 | gpios = <&gpio1 16 0>; |
| 70 | }; | 100 | }; |
| 71 | }; | 101 | }; |
| 102 | |||
| 103 | gpio_keys { | ||
| 104 | compatible = "gpio-keys"; | ||
| 105 | #address-cells = <1>; | ||
| 106 | #size-cells = <0>; | ||
| 107 | button@1 { | ||
| 108 | label = "OTB Button"; | ||
| 109 | linux,code = <133>; | ||
| 110 | gpios = <&gpio1 3 1>; | ||
| 111 | debounce-interval = <100>; | ||
| 112 | }; | ||
| 113 | button@2 { | ||
| 114 | label = "Reset"; | ||
| 115 | linux,code = <0x198>; | ||
| 116 | gpios = <&gpio0 12 1>; | ||
| 117 | debounce-interval = <100>; | ||
| 118 | }; | ||
| 119 | }; | ||
| 72 | }; | 120 | }; |
diff --git a/arch/arm/boot/dts/kirkwood.dtsi b/arch/arm/boot/dts/kirkwood.dtsi index cef9616f330a..4e5b8154a5be 100644 --- a/arch/arm/boot/dts/kirkwood.dtsi +++ b/arch/arm/boot/dts/kirkwood.dtsi | |||
| @@ -14,7 +14,8 @@ | |||
| 14 | 14 | ||
| 15 | ocp@f1000000 { | 15 | ocp@f1000000 { |
| 16 | compatible = "simple-bus"; | 16 | compatible = "simple-bus"; |
| 17 | ranges = <0 0xf1000000 0x4000000>; | 17 | ranges = <0x00000000 0xf1000000 0x4000000 |
| 18 | 0xf5000000 0xf5000000 0x0000400>; | ||
| 18 | #address-cells = <1>; | 19 | #address-cells = <1>; |
| 19 | #size-cells = <1>; | 20 | #size-cells = <1>; |
| 20 | 21 | ||
| @@ -105,5 +106,14 @@ | |||
| 105 | clock-frequency = <100000>; | 106 | clock-frequency = <100000>; |
| 106 | status = "disabled"; | 107 | status = "disabled"; |
| 107 | }; | 108 | }; |
| 109 | |||
| 110 | crypto@30000 { | ||
| 111 | compatible = "marvell,orion-crypto"; | ||
| 112 | reg = <0x30000 0x10000>, | ||
| 113 | <0xf5000000 0x800>; | ||
| 114 | reg-names = "regs", "sram"; | ||
| 115 | interrupts = <22>; | ||
| 116 | status = "okay"; | ||
| 117 | }; | ||
| 108 | }; | 118 | }; |
| 109 | }; | 119 | }; |
diff --git a/arch/arm/mach-kirkwood/board-dnskw.c b/arch/arm/mach-kirkwood/board-dnskw.c index 4ab35065a144..6ac7a8dc7b78 100644 --- a/arch/arm/mach-kirkwood/board-dnskw.c +++ b/arch/arm/mach-kirkwood/board-dnskw.c | |||
| @@ -19,7 +19,6 @@ | |||
| 19 | #include <linux/of.h> | 19 | #include <linux/of.h> |
| 20 | #include <linux/gpio.h> | 20 | #include <linux/gpio.h> |
| 21 | #include <linux/input.h> | 21 | #include <linux/input.h> |
| 22 | #include <linux/gpio-fan.h> | ||
| 23 | #include <linux/leds.h> | 22 | #include <linux/leds.h> |
| 24 | #include <asm/mach-types.h> | 23 | #include <asm/mach-types.h> |
| 25 | #include <asm/mach/arch.h> | 24 | #include <asm/mach/arch.h> |
| @@ -67,29 +66,6 @@ static unsigned int dnskw_mpp_config[] __initdata = { | |||
| 67 | 0 | 66 | 0 |
| 68 | }; | 67 | }; |
| 69 | 68 | ||
| 70 | /* Fan: ADDA AD045HB-G73 40mm 6000rpm@5v */ | ||
| 71 | static struct gpio_fan_speed dnskw_fan_speed[] = { | ||
| 72 | { 0, 0 }, | ||
| 73 | { 3000, 1 }, | ||
| 74 | { 6000, 2 }, | ||
| 75 | }; | ||
| 76 | static unsigned dnskw_fan_pins[] = {46, 45}; | ||
| 77 | |||
| 78 | static struct gpio_fan_platform_data dnskw_fan_data = { | ||
| 79 | .num_ctrl = ARRAY_SIZE(dnskw_fan_pins), | ||
| 80 | .ctrl = dnskw_fan_pins, | ||
| 81 | .num_speed = ARRAY_SIZE(dnskw_fan_speed), | ||
| 82 | .speed = dnskw_fan_speed, | ||
| 83 | }; | ||
| 84 | |||
| 85 | static struct platform_device dnskw_fan_device = { | ||
| 86 | .name = "gpio-fan", | ||
| 87 | .id = -1, | ||
| 88 | .dev = { | ||
| 89 | .platform_data = &dnskw_fan_data, | ||
| 90 | }, | ||
| 91 | }; | ||
| 92 | |||
| 93 | static void dnskw_power_off(void) | 69 | static void dnskw_power_off(void) |
| 94 | { | 70 | { |
| 95 | gpio_set_value(36, 1); | 71 | gpio_set_value(36, 1); |
| @@ -114,8 +90,6 @@ void __init dnskw_init(void) | |||
| 114 | kirkwood_ehci_init(); | 90 | kirkwood_ehci_init(); |
| 115 | kirkwood_ge00_init(&dnskw_ge00_data); | 91 | kirkwood_ge00_init(&dnskw_ge00_data); |
| 116 | 92 | ||
| 117 | platform_device_register(&dnskw_fan_device); | ||
| 118 | |||
| 119 | /* Register power-off GPIO. */ | 93 | /* Register power-off GPIO. */ |
| 120 | if (gpio_request(36, "dnskw:power:off") == 0 | 94 | if (gpio_request(36, "dnskw:power:off") == 0 |
| 121 | && gpio_direction_output(36, 0) == 0) | 95 | && gpio_direction_output(36, 0) == 0) |
diff --git a/arch/arm/mach-kirkwood/board-dt.c b/arch/arm/mach-kirkwood/board-dt.c index 496554664e08..70c5a2882409 100644 --- a/arch/arm/mach-kirkwood/board-dt.c +++ b/arch/arm/mach-kirkwood/board-dt.c | |||
| @@ -33,6 +33,7 @@ struct of_dev_auxdata kirkwood_auxdata_lookup[] __initdata = { | |||
| 33 | OF_DEV_AUXDATA("marvell,orion-wdt", 0xf1020300, "orion_wdt", NULL), | 33 | OF_DEV_AUXDATA("marvell,orion-wdt", 0xf1020300, "orion_wdt", NULL), |
| 34 | OF_DEV_AUXDATA("marvell,orion-sata", 0xf1080000, "sata_mv.0", NULL), | 34 | OF_DEV_AUXDATA("marvell,orion-sata", 0xf1080000, "sata_mv.0", NULL), |
| 35 | OF_DEV_AUXDATA("marvell,orion-nand", 0xf4000000, "orion_nand", NULL), | 35 | OF_DEV_AUXDATA("marvell,orion-nand", 0xf4000000, "orion_nand", NULL), |
| 36 | OF_DEV_AUXDATA("marvell,orion-crypto", 0xf1030000, "mv_crypto", NULL), | ||
| 36 | {}, | 37 | {}, |
| 37 | }; | 38 | }; |
| 38 | 39 | ||
| @@ -60,7 +61,6 @@ static void __init kirkwood_dt_init(void) | |||
| 60 | /* internal devices that every board has */ | 61 | /* internal devices that every board has */ |
| 61 | kirkwood_xor0_init(); | 62 | kirkwood_xor0_init(); |
| 62 | kirkwood_xor1_init(); | 63 | kirkwood_xor1_init(); |
| 63 | kirkwood_crypto_init(); | ||
| 64 | 64 | ||
| 65 | #ifdef CONFIG_KEXEC | 65 | #ifdef CONFIG_KEXEC |
| 66 | kexec_reinit = kirkwood_enable_pcie; | 66 | kexec_reinit = kirkwood_enable_pcie; |
diff --git a/arch/arm/mach-kirkwood/board-iconnect.c b/arch/arm/mach-kirkwood/board-iconnect.c index d7a9198ed300..d084b1e2943a 100644 --- a/arch/arm/mach-kirkwood/board-iconnect.c +++ b/arch/arm/mach-kirkwood/board-iconnect.c | |||
| @@ -16,11 +16,8 @@ | |||
| 16 | #include <linux/of_fdt.h> | 16 | #include <linux/of_fdt.h> |
| 17 | #include <linux/of_irq.h> | 17 | #include <linux/of_irq.h> |
| 18 | #include <linux/of_platform.h> | 18 | #include <linux/of_platform.h> |
| 19 | #include <linux/mtd/partitions.h> | ||
| 20 | #include <linux/mv643xx_eth.h> | 19 | #include <linux/mv643xx_eth.h> |
| 21 | #include <linux/gpio.h> | 20 | #include <linux/gpio.h> |
| 22 | #include <linux/input.h> | ||
| 23 | #include <linux/gpio_keys.h> | ||
| 24 | #include <asm/mach/arch.h> | 21 | #include <asm/mach/arch.h> |
| 25 | #include <mach/kirkwood.h> | 22 | #include <mach/kirkwood.h> |
| 26 | #include "common.h" | 23 | #include "common.h" |
| @@ -44,57 +41,12 @@ static unsigned int iconnect_mpp_config[] __initdata = { | |||
| 44 | 0 | 41 | 0 |
| 45 | }; | 42 | }; |
| 46 | 43 | ||
| 47 | static struct mtd_partition iconnect_nand_parts[] = { | ||
| 48 | { | ||
| 49 | .name = "flash", | ||
| 50 | .offset = 0, | ||
| 51 | .size = MTDPART_SIZ_FULL, | ||
| 52 | }, | ||
| 53 | }; | ||
| 54 | |||
| 55 | /* yikes... theses are the original input buttons */ | ||
| 56 | /* but I'm not convinced by the sw event choices */ | ||
| 57 | static struct gpio_keys_button iconnect_buttons[] = { | ||
| 58 | { | ||
| 59 | .type = EV_SW, | ||
| 60 | .code = SW_LID, | ||
| 61 | .gpio = 12, | ||
| 62 | .desc = "Reset Button", | ||
| 63 | .active_low = 1, | ||
| 64 | .debounce_interval = 100, | ||
| 65 | }, { | ||
| 66 | .type = EV_SW, | ||
| 67 | .code = SW_TABLET_MODE, | ||
| 68 | .gpio = 35, | ||
| 69 | .desc = "OTB Button", | ||
| 70 | .active_low = 1, | ||
| 71 | .debounce_interval = 100, | ||
| 72 | }, | ||
| 73 | }; | ||
| 74 | |||
| 75 | static struct gpio_keys_platform_data iconnect_button_data = { | ||
| 76 | .buttons = iconnect_buttons, | ||
| 77 | .nbuttons = ARRAY_SIZE(iconnect_buttons), | ||
| 78 | }; | ||
| 79 | |||
| 80 | static struct platform_device iconnect_button_device = { | ||
| 81 | .name = "gpio-keys", | ||
| 82 | .id = -1, | ||
| 83 | .num_resources = 0, | ||
| 84 | .dev = { | ||
| 85 | .platform_data = &iconnect_button_data, | ||
| 86 | }, | ||
| 87 | }; | ||
| 88 | |||
| 89 | void __init iconnect_init(void) | 44 | void __init iconnect_init(void) |
| 90 | { | 45 | { |
| 91 | kirkwood_mpp_conf(iconnect_mpp_config); | 46 | kirkwood_mpp_conf(iconnect_mpp_config); |
| 92 | kirkwood_nand_init(ARRAY_AND_SIZE(iconnect_nand_parts), 25); | ||
| 93 | 47 | ||
| 94 | kirkwood_ehci_init(); | 48 | kirkwood_ehci_init(); |
| 95 | kirkwood_ge00_init(&iconnect_ge00_data); | 49 | kirkwood_ge00_init(&iconnect_ge00_data); |
| 96 | |||
| 97 | platform_device_register(&iconnect_button_device); | ||
| 98 | } | 50 | } |
| 99 | 51 | ||
| 100 | static int __init iconnect_pci_init(void) | 52 | static int __init iconnect_pci_init(void) |
diff --git a/drivers/crypto/mv_cesa.c b/drivers/crypto/mv_cesa.c index 21c1a87032b7..24ccae453e79 100644 --- a/drivers/crypto/mv_cesa.c +++ b/drivers/crypto/mv_cesa.c | |||
| @@ -19,6 +19,9 @@ | |||
| 19 | #include <linux/clk.h> | 19 | #include <linux/clk.h> |
| 20 | #include <crypto/internal/hash.h> | 20 | #include <crypto/internal/hash.h> |
| 21 | #include <crypto/sha.h> | 21 | #include <crypto/sha.h> |
| 22 | #include <linux/of.h> | ||
| 23 | #include <linux/of_platform.h> | ||
| 24 | #include <linux/of_irq.h> | ||
| 22 | 25 | ||
| 23 | #include "mv_cesa.h" | 26 | #include "mv_cesa.h" |
| 24 | 27 | ||
| @@ -1062,7 +1065,10 @@ static int mv_probe(struct platform_device *pdev) | |||
| 1062 | goto err_unmap_reg; | 1065 | goto err_unmap_reg; |
| 1063 | } | 1066 | } |
| 1064 | 1067 | ||
| 1065 | irq = platform_get_irq(pdev, 0); | 1068 | if (pdev->dev.of_node) |
| 1069 | irq = irq_of_parse_and_map(pdev->dev.of_node, 0); | ||
| 1070 | else | ||
| 1071 | irq = platform_get_irq(pdev, 0); | ||
| 1066 | if (irq < 0 || irq == NO_IRQ) { | 1072 | if (irq < 0 || irq == NO_IRQ) { |
| 1067 | ret = irq; | 1073 | ret = irq; |
| 1068 | goto err_unmap_sram; | 1074 | goto err_unmap_sram; |
| @@ -1170,12 +1176,19 @@ static int mv_remove(struct platform_device *pdev) | |||
| 1170 | return 0; | 1176 | return 0; |
| 1171 | } | 1177 | } |
| 1172 | 1178 | ||
| 1179 | static const struct of_device_id mv_cesa_of_match_table[] = { | ||
| 1180 | { .compatible = "marvell,orion-crypto", }, | ||
| 1181 | {} | ||
| 1182 | }; | ||
| 1183 | MODULE_DEVICE_TABLE(of, mv_cesa_of_match_table); | ||
| 1184 | |||
| 1173 | static struct platform_driver marvell_crypto = { | 1185 | static struct platform_driver marvell_crypto = { |
| 1174 | .probe = mv_probe, | 1186 | .probe = mv_probe, |
| 1175 | .remove = mv_remove, | 1187 | .remove = __devexit_p(mv_remove), |
| 1176 | .driver = { | 1188 | .driver = { |
| 1177 | .owner = THIS_MODULE, | 1189 | .owner = THIS_MODULE, |
| 1178 | .name = "mv_crypto", | 1190 | .name = "mv_crypto", |
| 1191 | .of_match_table = of_match_ptr(mv_cesa_of_match_table), | ||
| 1179 | }, | 1192 | }, |
| 1180 | }; | 1193 | }; |
| 1181 | MODULE_ALIAS("platform:mv_crypto"); | 1194 | MODULE_ALIAS("platform:mv_crypto"); |
diff --git a/drivers/hwmon/gpio-fan.c b/drivers/hwmon/gpio-fan.c index 2f4b01bda87c..36509ae32083 100644 --- a/drivers/hwmon/gpio-fan.c +++ b/drivers/hwmon/gpio-fan.c | |||
| @@ -31,6 +31,8 @@ | |||
| 31 | #include <linux/hwmon.h> | 31 | #include <linux/hwmon.h> |
| 32 | #include <linux/gpio.h> | 32 | #include <linux/gpio.h> |
| 33 | #include <linux/gpio-fan.h> | 33 | #include <linux/gpio-fan.h> |
| 34 | #include <linux/of_platform.h> | ||
| 35 | #include <linux/of_gpio.h> | ||
| 34 | 36 | ||
| 35 | struct gpio_fan_data { | 37 | struct gpio_fan_data { |
| 36 | struct platform_device *pdev; | 38 | struct platform_device *pdev; |
| @@ -400,14 +402,131 @@ static ssize_t show_name(struct device *dev, | |||
| 400 | 402 | ||
| 401 | static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); | 403 | static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); |
| 402 | 404 | ||
| 405 | |||
| 406 | #ifdef CONFIG_OF_GPIO | ||
| 407 | /* | ||
| 408 | * Translate OpenFirmware node properties into platform_data | ||
| 409 | */ | ||
| 410 | static int gpio_fan_get_of_pdata(struct device *dev, | ||
| 411 | struct gpio_fan_platform_data *pdata) | ||
| 412 | { | ||
| 413 | struct device_node *node; | ||
| 414 | struct gpio_fan_speed *speed; | ||
| 415 | unsigned *ctrl; | ||
| 416 | unsigned i; | ||
| 417 | u32 u; | ||
| 418 | struct property *prop; | ||
| 419 | const __be32 *p; | ||
| 420 | |||
| 421 | node = dev->of_node; | ||
| 422 | |||
| 423 | /* Fill GPIO pin array */ | ||
| 424 | pdata->num_ctrl = of_gpio_count(node); | ||
| 425 | if (!pdata->num_ctrl) { | ||
| 426 | dev_err(dev, "gpios DT property empty / missing"); | ||
| 427 | return -ENODEV; | ||
| 428 | } | ||
| 429 | ctrl = devm_kzalloc(dev, pdata->num_ctrl * sizeof(unsigned), | ||
| 430 | GFP_KERNEL); | ||
| 431 | if (!ctrl) | ||
| 432 | return -ENOMEM; | ||
| 433 | for (i = 0; i < pdata->num_ctrl; i++) { | ||
| 434 | int val; | ||
| 435 | |||
| 436 | val = of_get_gpio(node, i); | ||
| 437 | if (val < 0) | ||
| 438 | return val; | ||
| 439 | ctrl[i] = val; | ||
| 440 | } | ||
| 441 | pdata->ctrl = ctrl; | ||
| 442 | |||
| 443 | /* Get number of RPM/ctrl_val pairs in speed map */ | ||
| 444 | prop = of_find_property(node, "gpio-fan,speed-map", &i); | ||
| 445 | if (!prop) { | ||
| 446 | dev_err(dev, "gpio-fan,speed-map DT property missing"); | ||
| 447 | return -ENODEV; | ||
| 448 | } | ||
| 449 | i = i / sizeof(u32); | ||
| 450 | if (i == 0 || i & 1) { | ||
| 451 | dev_err(dev, "gpio-fan,speed-map contains zero/odd number of entries"); | ||
| 452 | return -ENODEV; | ||
| 453 | } | ||
| 454 | pdata->num_speed = i / 2; | ||
| 455 | |||
| 456 | /* | ||
| 457 | * Populate speed map | ||
| 458 | * Speed map is in the form <RPM ctrl_val RPM ctrl_val ...> | ||
| 459 | * this needs splitting into pairs to create gpio_fan_speed structs | ||
| 460 | */ | ||
| 461 | speed = devm_kzalloc(dev, | ||
| 462 | pdata->num_speed * sizeof(struct gpio_fan_speed), | ||
| 463 | GFP_KERNEL); | ||
| 464 | if (!speed) | ||
| 465 | return -ENOMEM; | ||
| 466 | p = NULL; | ||
| 467 | for (i = 0; i < pdata->num_speed; i++) { | ||
| 468 | p = of_prop_next_u32(prop, p, &u); | ||
| 469 | if (!p) | ||
| 470 | return -ENODEV; | ||
| 471 | speed[i].rpm = u; | ||
| 472 | p = of_prop_next_u32(prop, p, &u); | ||
| 473 | if (!p) | ||
| 474 | return -ENODEV; | ||
| 475 | speed[i].ctrl_val = u; | ||
| 476 | } | ||
| 477 | pdata->speed = speed; | ||
| 478 | |||
| 479 | /* Alarm GPIO if one exists */ | ||
| 480 | if (of_gpio_named_count(node, "alarm-gpios")) { | ||
| 481 | struct gpio_fan_alarm *alarm; | ||
| 482 | int val; | ||
| 483 | enum of_gpio_flags flags; | ||
| 484 | |||
| 485 | alarm = devm_kzalloc(dev, sizeof(struct gpio_fan_alarm), | ||
| 486 | GFP_KERNEL); | ||
| 487 | if (!alarm) | ||
| 488 | return -ENOMEM; | ||
| 489 | |||
| 490 | val = of_get_named_gpio_flags(node, "alarm-gpios", 0, &flags); | ||
| 491 | if (val < 0) | ||
| 492 | return val; | ||
| 493 | alarm->gpio = val; | ||
| 494 | alarm->active_low = flags & OF_GPIO_ACTIVE_LOW; | ||
| 495 | |||
| 496 | pdata->alarm = alarm; | ||
| 497 | } | ||
| 498 | |||
| 499 | return 0; | ||
| 500 | } | ||
| 501 | |||
| 502 | static struct of_device_id of_gpio_fan_match[] __devinitdata = { | ||
| 503 | { .compatible = "gpio-fan", }, | ||
| 504 | {}, | ||
| 505 | }; | ||
| 506 | #endif /* CONFIG_OF_GPIO */ | ||
| 507 | |||
| 403 | static int __devinit gpio_fan_probe(struct platform_device *pdev) | 508 | static int __devinit gpio_fan_probe(struct platform_device *pdev) |
| 404 | { | 509 | { |
| 405 | int err; | 510 | int err; |
| 406 | struct gpio_fan_data *fan_data; | 511 | struct gpio_fan_data *fan_data; |
| 407 | struct gpio_fan_platform_data *pdata = pdev->dev.platform_data; | 512 | struct gpio_fan_platform_data *pdata = pdev->dev.platform_data; |
| 408 | 513 | ||
| 514 | #ifdef CONFIG_OF_GPIO | ||
| 515 | if (!pdata) { | ||
| 516 | pdata = devm_kzalloc(&pdev->dev, | ||
| 517 | sizeof(struct gpio_fan_platform_data), | ||
| 518 | GFP_KERNEL); | ||
| 519 | if (!pdata) | ||
| 520 | return -ENOMEM; | ||
| 521 | |||
| 522 | err = gpio_fan_get_of_pdata(&pdev->dev, pdata); | ||
| 523 | if (err) | ||
| 524 | return err; | ||
| 525 | } | ||
| 526 | #else /* CONFIG_OF_GPIO */ | ||
| 409 | if (!pdata) | 527 | if (!pdata) |
| 410 | return -EINVAL; | 528 | return -EINVAL; |
| 529 | #endif /* CONFIG_OF_GPIO */ | ||
| 411 | 530 | ||
| 412 | fan_data = devm_kzalloc(&pdev->dev, sizeof(struct gpio_fan_data), | 531 | fan_data = devm_kzalloc(&pdev->dev, sizeof(struct gpio_fan_data), |
| 413 | GFP_KERNEL); | 532 | GFP_KERNEL); |
| @@ -511,6 +630,7 @@ static struct platform_driver gpio_fan_driver = { | |||
| 511 | .driver = { | 630 | .driver = { |
| 512 | .name = "gpio-fan", | 631 | .name = "gpio-fan", |
| 513 | .pm = GPIO_FAN_PM, | 632 | .pm = GPIO_FAN_PM, |
| 633 | .of_match_table = of_match_ptr(of_gpio_fan_match), | ||
| 514 | }, | 634 | }, |
| 515 | }; | 635 | }; |
| 516 | 636 | ||
