aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Miao <eric.miao@marvell.com>2008-09-05 20:46:23 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2008-09-23 17:04:40 -0400
commitf72de6638b8e55283739de174b57c0ae4203c446 (patch)
tree6e3daf24ca74b0b4921747bddbf3a95bcaa2236b
parent4fe3224fffc56b13fe54e0fa479b64db83d8b125 (diff)
[ARM] pxa/akita: use pca953x instead of akita-ioexp
Use generic pca953x which provides gpiolib interface instead of akita-specific akita-ioexp with non-standard interface to pins. Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com> Cc: Richard Purdie <rpurdie@rpsys.net> Cc: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Eric Miao <eric.miao@marvell.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r--arch/arm/mach-pxa/Makefile1
-rw-r--r--arch/arm/mach-pxa/akita-ioexp.c222
-rw-r--r--arch/arm/mach-pxa/include/mach/akita.h32
-rw-r--r--arch/arm/mach-pxa/include/mach/spitz.h11
-rw-r--r--arch/arm/mach-pxa/spitz.c37
-rw-r--r--sound/soc/pxa/spitz.c13
6 files changed, 31 insertions, 285 deletions
diff --git a/arch/arm/mach-pxa/Makefile b/arch/arm/mach-pxa/Makefile
index 56f216298bcb..fbedaaf74bd3 100644
--- a/arch/arm/mach-pxa/Makefile
+++ b/arch/arm/mach-pxa/Makefile
@@ -30,7 +30,6 @@ obj-$(CONFIG_MACH_TRIZEPS4) += trizeps4.o
30obj-$(CONFIG_MACH_COLIBRI) += colibri.o 30obj-$(CONFIG_MACH_COLIBRI) += colibri.o
31obj-$(CONFIG_PXA_SHARP_C7xx) += corgi.o sharpsl_pm.o corgi_pm.o 31obj-$(CONFIG_PXA_SHARP_C7xx) += corgi.o sharpsl_pm.o corgi_pm.o
32obj-$(CONFIG_PXA_SHARP_Cxx00) += spitz.o sharpsl_pm.o spitz_pm.o 32obj-$(CONFIG_PXA_SHARP_Cxx00) += spitz.o sharpsl_pm.o spitz_pm.o
33obj-$(CONFIG_MACH_AKITA) += akita-ioexp.o
34obj-$(CONFIG_MACH_POODLE) += poodle.o 33obj-$(CONFIG_MACH_POODLE) += poodle.o
35obj-$(CONFIG_MACH_PCM027) += pcm027.o 34obj-$(CONFIG_MACH_PCM027) += pcm027.o
36obj-$(CONFIG_MACH_PCM990_BASEBOARD) += pcm990-baseboard.o 35obj-$(CONFIG_MACH_PCM990_BASEBOARD) += pcm990-baseboard.o
diff --git a/arch/arm/mach-pxa/akita-ioexp.c b/arch/arm/mach-pxa/akita-ioexp.c
deleted file mode 100644
index 5c67b188a3ba..000000000000
--- a/arch/arm/mach-pxa/akita-ioexp.c
+++ /dev/null
@@ -1,222 +0,0 @@
1/*
2 * Support for the Extra GPIOs on the Sharp SL-C1000 (Akita)
3 * (uses a Maxim MAX7310 8 Port IO Expander)
4 *
5 * Copyright 2005 Openedhand Ltd.
6 *
7 * Author: Richard Purdie <richard@openedhand.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 */
14
15#include <linux/kernel.h>
16#include <linux/init.h>
17#include <linux/platform_device.h>
18#include <linux/module.h>
19#include <linux/i2c.h>
20#include <linux/slab.h>
21#include <linux/workqueue.h>
22#include <mach/akita.h>
23
24/* MAX7310 Regiser Map */
25#define MAX7310_INPUT 0x00
26#define MAX7310_OUTPUT 0x01
27#define MAX7310_POLINV 0x02
28#define MAX7310_IODIR 0x03 /* 1 = Input, 0 = Output */
29#define MAX7310_TIMEOUT 0x04
30
31/* Addresses to scan */
32static const unsigned short normal_i2c[] = { 0x18, I2C_CLIENT_END };
33
34/* I2C Magic */
35I2C_CLIENT_INSMOD;
36
37static int max7310_write(struct i2c_client *client, int address, int data);
38static struct i2c_client max7310_template;
39static void akita_ioexp_work(struct work_struct *private_);
40
41static struct device *akita_ioexp_device;
42static unsigned char ioexp_output_value = AKITA_IOEXP_IO_OUT;
43DECLARE_WORK(akita_ioexp, akita_ioexp_work);
44
45
46/*
47 * MAX7310 Access
48 */
49static int max7310_config(struct device *dev, int iomode, int polarity)
50{
51 int ret;
52 struct i2c_client *client = to_i2c_client(dev);
53
54 ret = max7310_write(client, MAX7310_POLINV, polarity);
55 if (ret < 0)
56 return ret;
57 ret = max7310_write(client, MAX7310_IODIR, iomode);
58 return ret;
59}
60
61static int max7310_set_ouputs(struct device *dev, int outputs)
62{
63 struct i2c_client *client = to_i2c_client(dev);
64
65 return max7310_write(client, MAX7310_OUTPUT, outputs);
66}
67
68/*
69 * I2C Functions
70 */
71static int max7310_write(struct i2c_client *client, int address, int value)
72{
73 u8 data[2];
74
75 data[0] = address & 0xff;
76 data[1] = value & 0xff;
77
78 if (i2c_master_send(client, data, 2) == 2)
79 return 0;
80 return -1;
81}
82
83static int max7310_detect(struct i2c_adapter *adapter, int address, int kind)
84{
85 struct i2c_client *new_client;
86 int err;
87
88 if (!(new_client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL)))
89 return -ENOMEM;
90
91 max7310_template.adapter = adapter;
92 max7310_template.addr = address;
93
94 memcpy(new_client, &max7310_template, sizeof(struct i2c_client));
95
96 if ((err = i2c_attach_client(new_client))) {
97 kfree(new_client);
98 return err;
99 }
100
101 max7310_config(&new_client->dev, AKITA_IOEXP_IO_DIR, 0);
102 akita_ioexp_device = &new_client->dev;
103 schedule_work(&akita_ioexp);
104
105 return 0;
106}
107
108static int max7310_attach_adapter(struct i2c_adapter *adapter)
109{
110 return i2c_probe(adapter, &addr_data, max7310_detect);
111}
112
113static int max7310_detach_client(struct i2c_client *client)
114{
115 int err;
116
117 akita_ioexp_device = NULL;
118
119 if ((err = i2c_detach_client(client)))
120 return err;
121
122 kfree(client);
123 return 0;
124}
125
126static struct i2c_driver max7310_i2c_driver = {
127 .driver = {
128 .name = "akita-max7310",
129 },
130 .id = I2C_DRIVERID_AKITAIOEXP,
131 .attach_adapter = max7310_attach_adapter,
132 .detach_client = max7310_detach_client,
133};
134
135static struct i2c_client max7310_template = {
136 name: "akita-max7310",
137 driver: &max7310_i2c_driver,
138};
139
140void akita_set_ioexp(struct device *dev, unsigned char bit)
141{
142 ioexp_output_value |= bit;
143
144 if (akita_ioexp_device)
145 schedule_work(&akita_ioexp);
146 return;
147}
148
149void akita_reset_ioexp(struct device *dev, unsigned char bit)
150{
151 ioexp_output_value &= ~bit;
152
153 if (akita_ioexp_device)
154 schedule_work(&akita_ioexp);
155 return;
156}
157
158EXPORT_SYMBOL(akita_set_ioexp);
159EXPORT_SYMBOL(akita_reset_ioexp);
160
161static void akita_ioexp_work(struct work_struct *private_)
162{
163 if (akita_ioexp_device)
164 max7310_set_ouputs(akita_ioexp_device, ioexp_output_value);
165}
166
167
168#ifdef CONFIG_PM
169static int akita_ioexp_suspend(struct platform_device *pdev, pm_message_t state)
170{
171 flush_scheduled_work();
172 return 0;
173}
174
175static int akita_ioexp_resume(struct platform_device *pdev)
176{
177 schedule_work(&akita_ioexp);
178 return 0;
179}
180#else
181#define akita_ioexp_suspend NULL
182#define akita_ioexp_resume NULL
183#endif
184
185static int __init akita_ioexp_probe(struct platform_device *pdev)
186{
187 return i2c_add_driver(&max7310_i2c_driver);
188}
189
190static int akita_ioexp_remove(struct platform_device *pdev)
191{
192 i2c_del_driver(&max7310_i2c_driver);
193 return 0;
194}
195
196static struct platform_driver akita_ioexp_driver = {
197 .probe = akita_ioexp_probe,
198 .remove = akita_ioexp_remove,
199 .suspend = akita_ioexp_suspend,
200 .resume = akita_ioexp_resume,
201 .driver = {
202 .name = "akita-ioexp",
203 },
204};
205
206static int __init akita_ioexp_init(void)
207{
208 return platform_driver_register(&akita_ioexp_driver);
209}
210
211static void __exit akita_ioexp_exit(void)
212{
213 platform_driver_unregister(&akita_ioexp_driver);
214}
215
216MODULE_AUTHOR("Richard Purdie <rpurdie@openedhand.com>");
217MODULE_DESCRIPTION("Akita IO-Expander driver");
218MODULE_LICENSE("GPL");
219
220fs_initcall(akita_ioexp_init);
221module_exit(akita_ioexp_exit);
222
diff --git a/arch/arm/mach-pxa/include/mach/akita.h b/arch/arm/mach-pxa/include/mach/akita.h
deleted file mode 100644
index 5d8cc1d9cb10..000000000000
--- a/arch/arm/mach-pxa/include/mach/akita.h
+++ /dev/null
@@ -1,32 +0,0 @@
1/*
2 * Hardware specific definitions for SL-C1000 (Akita)
3 *
4 * Copyright (c) 2005 Richard Purdie
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 */
11
12/* Akita IO Expander GPIOs */
13
14#define AKITA_IOEXP_RESERVED_7 (1 << 7)
15#define AKITA_IOEXP_IR_ON (1 << 6)
16#define AKITA_IOEXP_AKIN_PULLUP (1 << 5)
17#define AKITA_IOEXP_BACKLIGHT_CONT (1 << 4)
18#define AKITA_IOEXP_BACKLIGHT_ON (1 << 3)
19#define AKITA_IOEXP_MIC_BIAS (1 << 2)
20#define AKITA_IOEXP_RESERVED_1 (1 << 1)
21#define AKITA_IOEXP_RESERVED_0 (1 << 0)
22
23/* Direction Bitfield 0=output 1=input */
24#define AKITA_IOEXP_IO_DIR 0
25/* Default Values */
26#define AKITA_IOEXP_IO_OUT (AKITA_IOEXP_IR_ON | AKITA_IOEXP_AKIN_PULLUP)
27
28extern struct platform_device akitaioexp_device;
29
30void akita_set_ioexp(struct device *dev, unsigned char bitmask);
31void akita_reset_ioexp(struct device *dev, unsigned char bitmask);
32
diff --git a/arch/arm/mach-pxa/include/mach/spitz.h b/arch/arm/mach-pxa/include/mach/spitz.h
index 3e28394333e7..31ac26b55bc1 100644
--- a/arch/arm/mach-pxa/include/mach/spitz.h
+++ b/arch/arm/mach-pxa/include/mach/spitz.h
@@ -151,6 +151,17 @@
151#define SPITZ_GPIO_BACKLIGHT_ON (SPITZ_SCP2_GPIO_BASE + 7) 151#define SPITZ_GPIO_BACKLIGHT_ON (SPITZ_SCP2_GPIO_BASE + 7)
152#define SPITZ_GPIO_MIC_BIAS (SPITZ_SCP2_GPIO_BASE + 8) 152#define SPITZ_GPIO_MIC_BIAS (SPITZ_SCP2_GPIO_BASE + 8)
153 153
154/* Akita IO Expander GPIOs */
155#define AKITA_IOEXP_GPIO_BASE (NR_BUILTIN_GPIO + 12)
156#define AKITA_GPIO_RESERVED_0 (AKITA_IOEXP_GPIO_BASE + 0)
157#define AKITA_GPIO_RESERVED_1 (AKITA_IOEXP_GPIO_BASE + 1)
158#define AKITA_GPIO_MIC_BIAS (AKITA_IOEXP_GPIO_BASE + 2)
159#define AKITA_GPIO_BACKLIGHT_ON (AKITA_IOEXP_GPIO_BASE + 3)
160#define AKITA_GPIO_BACKLIGHT_CONT (AKITA_IOEXP_GPIO_BASE + 4)
161#define AKITA_GPIO_AKIN_PULLUP (AKITA_IOEXP_GPIO_BASE + 5)
162#define AKITA_GPIO_IR_ON (AKITA_IOEXP_GPIO_BASE + 6)
163#define AKITA_GPIO_RESERVED_7 (AKITA_IOEXP_GPIO_BASE + 7)
164
154/* Spitz IRQ Definitions */ 165/* Spitz IRQ Definitions */
155 166
156#define SPITZ_IRQ_GPIO_KEY_INT IRQ_GPIO(SPITZ_GPIO_KEY_INT) 167#define SPITZ_IRQ_GPIO_KEY_INT IRQ_GPIO(SPITZ_GPIO_KEY_INT)
diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c
index 993a132ff978..1d8654d2fb96 100644
--- a/arch/arm/mach-pxa/spitz.c
+++ b/arch/arm/mach-pxa/spitz.c
@@ -24,6 +24,8 @@
24#include <linux/mmc/host.h> 24#include <linux/mmc/host.h>
25#include <linux/pm.h> 25#include <linux/pm.h>
26#include <linux/backlight.h> 26#include <linux/backlight.h>
27#include <linux/i2c.h>
28#include <linux/i2c/pca953x.h>
27#include <linux/spi/spi.h> 29#include <linux/spi/spi.h>
28#include <linux/spi/ads7846.h> 30#include <linux/spi/ads7846.h>
29#include <linux/spi/corgi_lcd.h> 31#include <linux/spi/corgi_lcd.h>
@@ -52,7 +54,6 @@
52#include <mach/udc.h> 54#include <mach/udc.h>
53#include <mach/pxafb.h> 55#include <mach/pxafb.h>
54#include <mach/pxa2xx_spi.h> 56#include <mach/pxa2xx_spi.h>
55#include <mach/akita.h>
56#include <mach/spitz.h> 57#include <mach/spitz.h>
57#include <mach/sharpsl.h> 58#include <mach/sharpsl.h>
58 59
@@ -313,16 +314,8 @@ static void spitz_notify_intensity(int intensity)
313 } 314 }
314 315
315 if (machine_is_akita()) { 316 if (machine_is_akita()) {
316 /* Bit 5 is via IO-Expander */ 317 gpio_set_value(AKITA_GPIO_BACKLIGHT_CONT, !(intensity & 0x20));
317 if (intensity & 0x0020) 318 gpio_set_value(AKITA_GPIO_BACKLIGHT_ON, intensity);
318 akita_reset_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_BACKLIGHT_CONT);
319 else
320 akita_set_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_BACKLIGHT_CONT);
321
322 if (intensity)
323 akita_set_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_BACKLIGHT_ON);
324 else
325 akita_reset_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_BACKLIGHT_ON);
326 return; 319 return;
327 } 320 }
328} 321}
@@ -565,10 +558,7 @@ static void spitz_irda_transceiver_mode(struct device *dev, int mode)
565#ifdef CONFIG_MACH_AKITA 558#ifdef CONFIG_MACH_AKITA
566static void akita_irda_transceiver_mode(struct device *dev, int mode) 559static void akita_irda_transceiver_mode(struct device *dev, int mode)
567{ 560{
568 if (mode & IR_OFF) 561 gpio_set_value(AKITA_GPIO_IR_ON, mode & IR_OFF);
569 akita_set_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_IR_ON);
570 else
571 akita_reset_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_IR_ON);
572 pxa2xx_transceiver_mode(dev, mode); 562 pxa2xx_transceiver_mode(dev, mode);
573} 563}
574#endif 564#endif
@@ -679,12 +669,17 @@ static void __init spitz_init(void)
679/* 669/*
680 * Akita IO Expander 670 * Akita IO Expander
681 */ 671 */
682struct platform_device akitaioexp_device = { 672static struct pca953x_platform_data akita_ioexp = {
683 .name = "akita-ioexp", 673 .gpio_base = AKITA_IOEXP_GPIO_BASE,
684 .id = -1,
685}; 674};
686 675
687EXPORT_SYMBOL_GPL(akitaioexp_device); 676static struct i2c_board_info akita_i2c_board_info[] = {
677 {
678 .type = "max7310",
679 .addr = 0x18,
680 .platform_data = &akita_ioexp,
681 },
682};
688 683
689static void __init akita_init(void) 684static void __init akita_init(void)
690{ 685{
@@ -694,9 +689,9 @@ static void __init akita_init(void)
694 spitz_pcmcia_config.num_devs = 1; 689 spitz_pcmcia_config.num_devs = 1;
695 platform_scoop_config = &spitz_pcmcia_config; 690 platform_scoop_config = &spitz_pcmcia_config;
696 691
697 platform_device_register(&akitaioexp_device); 692 pxa_set_i2c_info(NULL);
693 i2c_register_board_info(0, ARRAY_AND_SIZE(akita_i2c_board_info));
698 694
699 spitzscoop_device.dev.parent = &akitaioexp_device.dev;
700 common_init(); 695 common_init();
701} 696}
702#endif 697#endif
diff --git a/sound/soc/pxa/spitz.c b/sound/soc/pxa/spitz.c
index acfa712844e2..b89a3edd2183 100644
--- a/sound/soc/pxa/spitz.c
+++ b/sound/soc/pxa/spitz.c
@@ -28,7 +28,6 @@
28#include <asm/mach-types.h> 28#include <asm/mach-types.h>
29#include <mach/pxa-regs.h> 29#include <mach/pxa-regs.h>
30#include <mach/hardware.h> 30#include <mach/hardware.h>
31#include <mach/akita.h>
32#include <mach/spitz.h> 31#include <mach/spitz.h>
33#include "../codecs/wm8750.h" 32#include "../codecs/wm8750.h"
34#include "pxa2xx-pcm.h" 33#include "pxa2xx-pcm.h"
@@ -219,14 +218,10 @@ static int spitz_mic_bias(struct snd_soc_dapm_widget *w,
219 gpio_set_value(SPITZ_GPIO_MIC_BIAS, 218 gpio_set_value(SPITZ_GPIO_MIC_BIAS,
220 SND_SOC_DAPM_EVENT_ON(event)); 219 SND_SOC_DAPM_EVENT_ON(event));
221 220
222 if (machine_is_akita()) { 221 if (machine_is_akita())
223 if (SND_SOC_DAPM_EVENT_ON(event)) 222 gpio_set_value(AKITA_GPIO_MIC_BIAS,
224 akita_set_ioexp(&akitaioexp_device.dev, 223 SND_SOC_DAPM_EVENT_ON(event));
225 AKITA_IOEXP_MIC_BIAS); 224
226 else
227 akita_reset_ioexp(&akitaioexp_device.dev,
228 AKITA_IOEXP_MIC_BIAS);
229 }
230 return 0; 225 return 0;
231} 226}
232 227