aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input
diff options
context:
space:
mode:
authorJanusz Krzysztofik <jkrzyszt@tis.icnet.pl>2011-12-20 17:10:34 -0500
committerTony Lindgren <tony@atomide.com>2011-12-22 12:00:46 -0500
commit8d09a1bb3147ddbcf0a9483021ca699c54c54732 (patch)
tree5d968498a2d40612b94e93831ce6f59d9cb355cc /drivers/input
parenta218d19f6a91c076c7ed8a7c0082f777248c5394 (diff)
input: serio: ams-delta: toggle keyboard power over GPIO
Don't use Amstrad Delta custom I/O functions once GPIO interface is available for the underlying hardware. While requesting and initializing GPIO pins used, also take care of one extra pin KEYBRD_DATAOUT which, even if not used by the driver, belongs to the device and affects its functioning. Once done, move the driver initialization back to the device_initcall level, reverting the temporary chane introduced with patch 1/7 "ARM: OMAP1: ams-delta: register latch dependent devices later". That change is no longer required once the driver takes care of registering used GPIO pins, and it's better to initialize the device before others using the latch2 based GPIO pins, otherwise a garbage is reported on boot, perhaps due to random data already captured by the FIQ handler while the keyboard related latch bits are written with random values during initialization of those other latch2 dependent devices. Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> Acked-by: Dmitry Torokhov <dtor@mail.ru> [tony@atomide.com: renamed _gpios to ams_delta_gpios] Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/serio/ams_delta_serio.c56
1 files changed, 35 insertions, 21 deletions
diff --git a/drivers/input/serio/ams_delta_serio.c b/drivers/input/serio/ams_delta_serio.c
index 835d37abe62..0571e2ec358 100644
--- a/drivers/input/serio/ams_delta_serio.c
+++ b/drivers/input/serio/ams_delta_serio.c
@@ -92,8 +92,7 @@ static irqreturn_t ams_delta_serio_interrupt(int irq, void *dev_id)
92static int ams_delta_serio_open(struct serio *serio) 92static int ams_delta_serio_open(struct serio *serio)
93{ 93{
94 /* enable keyboard */ 94 /* enable keyboard */
95 ams_delta_latch2_write(AMD_DELTA_LATCH2_KEYBRD_PWR, 95 gpio_set_value(AMS_DELTA_GPIO_PIN_KEYBRD_PWR, 1);
96 AMD_DELTA_LATCH2_KEYBRD_PWR);
97 96
98 return 0; 97 return 0;
99} 98}
@@ -101,9 +100,32 @@ static int ams_delta_serio_open(struct serio *serio)
101static void ams_delta_serio_close(struct serio *serio) 100static void ams_delta_serio_close(struct serio *serio)
102{ 101{
103 /* disable keyboard */ 102 /* disable keyboard */
104 ams_delta_latch2_write(AMD_DELTA_LATCH2_KEYBRD_PWR, 0); 103 gpio_set_value(AMS_DELTA_GPIO_PIN_KEYBRD_PWR, 0);
105} 104}
106 105
106static struct gpio ams_delta_gpios[] __initconst_or_module = {
107 {
108 .gpio = AMS_DELTA_GPIO_PIN_KEYBRD_DATA,
109 .flags = GPIOF_DIR_IN,
110 .label = "serio-data",
111 },
112 {
113 .gpio = AMS_DELTA_GPIO_PIN_KEYBRD_CLK,
114 .flags = GPIOF_DIR_IN,
115 .label = "serio-clock",
116 },
117 {
118 .gpio = AMS_DELTA_GPIO_PIN_KEYBRD_PWR,
119 .flags = GPIOF_OUT_INIT_LOW,
120 .label = "serio-power",
121 },
122 {
123 .gpio = AMS_DELTA_GPIO_PIN_KEYBRD_DATAOUT,
124 .flags = GPIOF_OUT_INIT_LOW,
125 .label = "serio-dataout",
126 },
127};
128
107static int __init ams_delta_serio_init(void) 129static int __init ams_delta_serio_init(void)
108{ 130{
109 int err; 131 int err;
@@ -123,19 +145,12 @@ static int __init ams_delta_serio_init(void)
123 strlcpy(ams_delta_serio->phys, "GPIO/serio0", 145 strlcpy(ams_delta_serio->phys, "GPIO/serio0",
124 sizeof(ams_delta_serio->phys)); 146 sizeof(ams_delta_serio->phys));
125 147
126 err = gpio_request(AMS_DELTA_GPIO_PIN_KEYBRD_DATA, "serio-data"); 148 err = gpio_request_array(ams_delta_gpios,
149 ARRAY_SIZE(ams_delta_gpios));
127 if (err) { 150 if (err) {
128 pr_err("ams_delta_serio: Couldn't request gpio pin for data\n"); 151 pr_err("ams_delta_serio: Couldn't request gpio pins\n");
129 goto serio; 152 goto serio;
130 } 153 }
131 gpio_direction_input(AMS_DELTA_GPIO_PIN_KEYBRD_DATA);
132
133 err = gpio_request(AMS_DELTA_GPIO_PIN_KEYBRD_CLK, "serio-clock");
134 if (err) {
135 pr_err("ams_delta_serio: couldn't request gpio pin for clock\n");
136 goto gpio_data;
137 }
138 gpio_direction_input(AMS_DELTA_GPIO_PIN_KEYBRD_CLK);
139 154
140 err = request_irq(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), 155 err = request_irq(gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK),
141 ams_delta_serio_interrupt, IRQ_TYPE_EDGE_RISING, 156 ams_delta_serio_interrupt, IRQ_TYPE_EDGE_RISING,
@@ -143,7 +158,7 @@ static int __init ams_delta_serio_init(void)
143 if (err < 0) { 158 if (err < 0) {
144 pr_err("ams_delta_serio: couldn't request gpio interrupt %d\n", 159 pr_err("ams_delta_serio: couldn't request gpio interrupt %d\n",
145 gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK)); 160 gpio_to_irq(AMS_DELTA_GPIO_PIN_KEYBRD_CLK));
146 goto gpio_clk; 161 goto gpio;
147 } 162 }
148 /* 163 /*
149 * Since GPIO register handling for keyboard clock pin is performed 164 * Since GPIO register handling for keyboard clock pin is performed
@@ -157,21 +172,20 @@ static int __init ams_delta_serio_init(void)
157 dev_info(&ams_delta_serio->dev, "%s\n", ams_delta_serio->name); 172 dev_info(&ams_delta_serio->dev, "%s\n", ams_delta_serio->name);
158 173
159 return 0; 174 return 0;
160gpio_clk: 175gpio:
161 gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_CLK); 176 gpio_free_array(ams_delta_gpios,
162gpio_data: 177 ARRAY_SIZE(ams_delta_gpios));
163 gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_DATA);
164serio: 178serio:
165 kfree(ams_delta_serio); 179 kfree(ams_delta_serio);
166 return err; 180 return err;
167} 181}
168late_initcall(ams_delta_serio_init); 182module_init(ams_delta_serio_init);
169 183
170static void __exit ams_delta_serio_exit(void) 184static void __exit ams_delta_serio_exit(void)
171{ 185{
172 serio_unregister_port(ams_delta_serio); 186 serio_unregister_port(ams_delta_serio);
173 free_irq(OMAP_GPIO_IRQ(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), 0); 187 free_irq(OMAP_GPIO_IRQ(AMS_DELTA_GPIO_PIN_KEYBRD_CLK), 0);
174 gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_CLK); 188 gpio_free_array(ams_delta_gpios,
175 gpio_free(AMS_DELTA_GPIO_PIN_KEYBRD_DATA); 189 ARRAY_SIZE(ams_delta_gpios));
176} 190}
177module_exit(ams_delta_serio_exit); 191module_exit(ams_delta_serio_exit);