blob: 4f5150c417a205dba7d5fc1d7e9cb19d67924bf7 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * i2c-au1550.c: SMBus (i2c) adapter for Alchemy PSC interface
3 * Copyright (C) 2004 Embedded Edge, LLC <dan@embeddededge.com>
4 *
5 * 2.6 port by Matt Porter <mporter@kernel.crashing.org>
6 *
7 * The documentation describes this as an SMBus controller, but it doesn't
8 * understand any of the SMBus protocol in hardware. It's really an I2C
9 * controller that could emulate most of the SMBus in software.
10 *
11 * This is just a skeleton adapter to use with the Au1550 PSC
12 * algorithm. It was developed for the Pb1550, but will work with
13 * any Au1550 board that has a similar PSC configuration.
14 *
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 */
29
Linus Torvalds1da177e2005-04-16 15:20:36 -070030#include <linux/delay.h>
31#include <linux/kernel.h>
32#include <linux/module.h>
Manuel Lauss8b798c42008-01-27 18:14:52 +010033#include <linux/platform_device.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070034#include <linux/init.h>
35#include <linux/errno.h>
36#include <linux/i2c.h>
Manuel Lauss8b798c42008-01-27 18:14:52 +010037#include <linux/slab.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
Domen Puncera294de42006-08-13 23:37:13 +020039#include <asm/mach-au1x00/au1xxx.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070040#include <asm/mach-au1x00/au1xxx_psc.h>
41
Manuel Laussc5de6462011-10-22 13:34:36 +020042#define PSC_SEL 0x00
43#define PSC_CTRL 0x04
44#define PSC_SMBCFG 0x08
45#define PSC_SMBMSK 0x0C
46#define PSC_SMBPCR 0x10
47#define PSC_SMBSTAT 0x14
48#define PSC_SMBEVNT 0x18
49#define PSC_SMBTXRX 0x1C
50#define PSC_SMBTMR 0x20
51
Manuel Lauss8b798c42008-01-27 18:14:52 +010052struct i2c_au1550_data {
Manuel Laussc5de6462011-10-22 13:34:36 +020053 void __iomem *psc_base;
Manuel Lauss8b798c42008-01-27 18:14:52 +010054 int xfer_timeout;
Manuel Lauss8b798c42008-01-27 18:14:52 +010055 struct i2c_adapter adap;
56 struct resource *ioarea;
57};
Linus Torvalds1da177e2005-04-16 15:20:36 -070058
Manuel Laussc5de6462011-10-22 13:34:36 +020059static inline void WR(struct i2c_au1550_data *a, int r, unsigned long v)
Linus Torvalds1da177e2005-04-16 15:20:36 -070060{
Manuel Laussc5de6462011-10-22 13:34:36 +020061 __raw_writel(v, a->psc_base + r);
62 wmb();
63}
Linus Torvalds1da177e2005-04-16 15:20:36 -070064
Manuel Laussc5de6462011-10-22 13:34:36 +020065static inline unsigned long RD(struct i2c_au1550_data *a, int r)
66{
67 return __raw_readl(a->psc_base + r);
68}
Linus Torvalds1da177e2005-04-16 15:20:36 -070069
Manuel Laussc5de6462011-10-22 13:34:36 +020070static int wait_xfer_done(struct i2c_au1550_data *adap)
71{
72 int i;
73
74 /* Wait for Tx Buffer Empty */
Linus Torvalds1da177e2005-04-16 15:20:36 -070075 for (i = 0; i < adap->xfer_timeout; i++) {
Manuel Laussc5de6462011-10-22 13:34:36 +020076 if (RD(adap, PSC_SMBSTAT) & PSC_SMBSTAT_TE)
Linus Torvalds1da177e2005-04-16 15:20:36 -070077 return 0;
Chris Davida2027072007-10-13 23:56:33 +020078
Linus Torvalds1da177e2005-04-16 15:20:36 -070079 udelay(1);
80 }
81
82 return -ETIMEDOUT;
83}
84
Manuel Laussc5de6462011-10-22 13:34:36 +020085static int wait_ack(struct i2c_au1550_data *adap)
Linus Torvalds1da177e2005-04-16 15:20:36 -070086{
Manuel Laussc5de6462011-10-22 13:34:36 +020087 unsigned long stat;
Linus Torvalds1da177e2005-04-16 15:20:36 -070088
89 if (wait_xfer_done(adap))
90 return -ETIMEDOUT;
91
Manuel Laussc5de6462011-10-22 13:34:36 +020092 stat = RD(adap, PSC_SMBEVNT);
Linus Torvalds1da177e2005-04-16 15:20:36 -070093 if ((stat & (PSC_SMBEVNT_DN | PSC_SMBEVNT_AN | PSC_SMBEVNT_AL)) != 0)
94 return -ETIMEDOUT;
95
96 return 0;
97}
98
Manuel Laussc5de6462011-10-22 13:34:36 +020099static int wait_master_done(struct i2c_au1550_data *adap)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100{
Manuel Laussc5de6462011-10-22 13:34:36 +0200101 int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102
Manuel Laussc5de6462011-10-22 13:34:36 +0200103 /* Wait for Master Done. */
Manuel Lauss84785f12011-10-22 13:34:38 +0200104 for (i = 0; i < 2 * adap->xfer_timeout; i++) {
Manuel Laussc5de6462011-10-22 13:34:36 +0200105 if ((RD(adap, PSC_SMBEVNT) & PSC_SMBEVNT_MD) != 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106 return 0;
107 udelay(1);
108 }
109
110 return -ETIMEDOUT;
111}
112
113static int
Manuel Lauss91f27952008-01-27 18:14:52 +0100114do_address(struct i2c_au1550_data *adap, unsigned int addr, int rd, int q)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115{
Manuel Laussc5de6462011-10-22 13:34:36 +0200116 unsigned long stat;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117
Manuel Laussc5de6462011-10-22 13:34:36 +0200118 /* Reset the FIFOs, clear events. */
119 stat = RD(adap, PSC_SMBSTAT);
120 WR(adap, PSC_SMBEVNT, PSC_SMBEVNT_ALLCLR);
Domen Puncer88599422006-08-13 23:35:40 +0200121
122 if (!(stat & PSC_SMBSTAT_TE) || !(stat & PSC_SMBSTAT_RE)) {
Manuel Laussc5de6462011-10-22 13:34:36 +0200123 WR(adap, PSC_SMBPCR, PSC_SMBPCR_DC);
124 while ((RD(adap, PSC_SMBPCR) & PSC_SMBPCR_DC) != 0)
125 cpu_relax();
Domen Puncer88599422006-08-13 23:35:40 +0200126 udelay(50);
127 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128
Manuel Laussc5de6462011-10-22 13:34:36 +0200129 /* Write out the i2c chip address and specify operation */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130 addr <<= 1;
131 if (rd)
132 addr |= 1;
133
Manuel Lauss91f27952008-01-27 18:14:52 +0100134 /* zero-byte xfers stop immediately */
135 if (q)
136 addr |= PSC_SMBTXRX_STP;
137
Manuel Laussc5de6462011-10-22 13:34:36 +0200138 /* Put byte into fifo, start up master. */
139 WR(adap, PSC_SMBTXRX, addr);
140 WR(adap, PSC_SMBPCR, PSC_SMBPCR_MS);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141 if (wait_ack(adap))
142 return -EIO;
Manuel Lauss91f27952008-01-27 18:14:52 +0100143 return (q) ? wait_master_done(adap) : 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144}
145
Manuel Laussc5de6462011-10-22 13:34:36 +0200146static int wait_for_rx_byte(struct i2c_au1550_data *adap, unsigned char *out)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147{
Manuel Laussc5de6462011-10-22 13:34:36 +0200148 int j;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149
150 if (wait_xfer_done(adap))
151 return -EIO;
152
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153 j = adap->xfer_timeout * 100;
154 do {
155 j--;
156 if (j <= 0)
157 return -EIO;
158
Manuel Laussc5de6462011-10-22 13:34:36 +0200159 if ((RD(adap, PSC_SMBSTAT) & PSC_SMBSTAT_RE) == 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160 j = 0;
161 else
162 udelay(1);
163 } while (j > 0);
Manuel Laussc5de6462011-10-22 13:34:36 +0200164
165 *out = RD(adap, PSC_SMBTXRX);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166
167 return 0;
168}
169
Manuel Laussc5de6462011-10-22 13:34:36 +0200170static int i2c_read(struct i2c_au1550_data *adap, unsigned char *buf,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171 unsigned int len)
172{
Manuel Laussc5de6462011-10-22 13:34:36 +0200173 int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174
175 if (len == 0)
176 return 0;
177
178 /* A read is performed by stuffing the transmit fifo with
179 * zero bytes for timing, waiting for bytes to appear in the
180 * receive fifo, then reading the bytes.
181 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182 i = 0;
Manuel Laussc5de6462011-10-22 13:34:36 +0200183 while (i < (len - 1)) {
184 WR(adap, PSC_SMBTXRX, 0);
185 if (wait_for_rx_byte(adap, &buf[i]))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186 return -EIO;
187
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188 i++;
189 }
190
Manuel Laussc5de6462011-10-22 13:34:36 +0200191 /* The last byte has to indicate transfer done. */
192 WR(adap, PSC_SMBTXRX, PSC_SMBTXRX_STP);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193 if (wait_master_done(adap))
194 return -EIO;
195
Manuel Laussc5de6462011-10-22 13:34:36 +0200196 buf[i] = (unsigned char)(RD(adap, PSC_SMBTXRX) & 0xff);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197 return 0;
198}
199
Manuel Laussc5de6462011-10-22 13:34:36 +0200200static int i2c_write(struct i2c_au1550_data *adap, unsigned char *buf,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201 unsigned int len)
202{
Manuel Laussc5de6462011-10-22 13:34:36 +0200203 int i;
204 unsigned long data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205
206 if (len == 0)
207 return 0;
208
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209 i = 0;
210 while (i < (len-1)) {
211 data = buf[i];
Manuel Laussc5de6462011-10-22 13:34:36 +0200212 WR(adap, PSC_SMBTXRX, data);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213 if (wait_ack(adap))
214 return -EIO;
215 i++;
216 }
217
Manuel Laussc5de6462011-10-22 13:34:36 +0200218 /* The last byte has to indicate transfer done. */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219 data = buf[i];
220 data |= PSC_SMBTXRX_STP;
Manuel Laussc5de6462011-10-22 13:34:36 +0200221 WR(adap, PSC_SMBTXRX, data);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222 if (wait_master_done(adap))
223 return -EIO;
224 return 0;
225}
226
227static int
228au1550_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs, int num)
229{
230 struct i2c_au1550_data *adap = i2c_adap->algo_data;
231 struct i2c_msg *p;
232 int i, err = 0;
233
Manuel Laussc5de6462011-10-22 13:34:36 +0200234 WR(adap, PSC_CTRL, PSC_CTRL_ENABLE);
Manuel Laussf09f71b2008-07-14 22:38:34 +0200235
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236 for (i = 0; !err && i < num; i++) {
237 p = &msgs[i];
Manuel Lauss91f27952008-01-27 18:14:52 +0100238 err = do_address(adap, p->addr, p->flags & I2C_M_RD,
239 (p->len == 0));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240 if (err || !p->len)
241 continue;
242 if (p->flags & I2C_M_RD)
243 err = i2c_read(adap, p->buf, p->len);
244 else
245 err = i2c_write(adap, p->buf, p->len);
246 }
247
248 /* Return the number of messages processed, or the error code.
249 */
250 if (err == 0)
251 err = num;
Manuel Laussf09f71b2008-07-14 22:38:34 +0200252
Manuel Laussc5de6462011-10-22 13:34:36 +0200253 WR(adap, PSC_CTRL, PSC_CTRL_SUSPEND);
Manuel Laussf09f71b2008-07-14 22:38:34 +0200254
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255 return err;
256}
257
Manuel Laussc5de6462011-10-22 13:34:36 +0200258static u32 au1550_func(struct i2c_adapter *adap)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259{
Domen Puncer6ed07132006-08-13 23:36:27 +0200260 return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261}
262
Jean Delvare8f9082c2006-09-03 22:39:46 +0200263static const struct i2c_algorithm au1550_algo = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264 .master_xfer = au1550_xfer,
265 .functionality = au1550_func,
266};
267
Manuel Laussf09f71b2008-07-14 22:38:34 +0200268static void i2c_au1550_setup(struct i2c_au1550_data *priv)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269{
Manuel Laussc5de6462011-10-22 13:34:36 +0200270 unsigned long cfg;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271
Manuel Laussc5de6462011-10-22 13:34:36 +0200272 WR(priv, PSC_CTRL, PSC_CTRL_DISABLE);
273 WR(priv, PSC_SEL, PSC_SEL_PS_SMBUSMODE);
274 WR(priv, PSC_SMBCFG, 0);
275 WR(priv, PSC_CTRL, PSC_CTRL_ENABLE);
276 while ((RD(priv, PSC_SMBSTAT) & PSC_SMBSTAT_SR) == 0)
277 cpu_relax();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278
Manuel Laussc5de6462011-10-22 13:34:36 +0200279 cfg = PSC_SMBCFG_RT_FIFO8 | PSC_SMBCFG_TT_FIFO8 | PSC_SMBCFG_DD_DISABLE;
280 WR(priv, PSC_SMBCFG, cfg);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281
282 /* Divide by 8 to get a 6.25 MHz clock. The later protocol
283 * timings are based on this clock.
284 */
Manuel Laussc5de6462011-10-22 13:34:36 +0200285 cfg |= PSC_SMBCFG_SET_DIV(PSC_SMBCFG_DIV8);
286 WR(priv, PSC_SMBCFG, cfg);
287 WR(priv, PSC_SMBMSK, PSC_SMBMSK_ALLMASK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288
289 /* Set the protocol timer values. See Table 71 in the
290 * Au1550 Data Book for standard timing values.
291 */
Manuel Laussc5de6462011-10-22 13:34:36 +0200292 WR(priv, PSC_SMBTMR, PSC_SMBTMR_SET_TH(0) | PSC_SMBTMR_SET_PS(15) | \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700293 PSC_SMBTMR_SET_PU(15) | PSC_SMBTMR_SET_SH(15) | \
294 PSC_SMBTMR_SET_SU(15) | PSC_SMBTMR_SET_CL(15) | \
Manuel Laussc5de6462011-10-22 13:34:36 +0200295 PSC_SMBTMR_SET_CH(15));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296
Manuel Laussc5de6462011-10-22 13:34:36 +0200297 cfg |= PSC_SMBCFG_DE_ENABLE;
298 WR(priv, PSC_SMBCFG, cfg);
299 while ((RD(priv, PSC_SMBSTAT) & PSC_SMBSTAT_SR) == 0)
300 cpu_relax();
Manuel Laussf09f71b2008-07-14 22:38:34 +0200301
Manuel Laussc5de6462011-10-22 13:34:36 +0200302 WR(priv, PSC_CTRL, PSC_CTRL_SUSPEND);
Manuel Laussf09f71b2008-07-14 22:38:34 +0200303}
304
305static void i2c_au1550_disable(struct i2c_au1550_data *priv)
306{
Manuel Laussc5de6462011-10-22 13:34:36 +0200307 WR(priv, PSC_SMBCFG, 0);
308 WR(priv, PSC_CTRL, PSC_CTRL_DISABLE);
Manuel Laussf09f71b2008-07-14 22:38:34 +0200309}
310
311/*
312 * registering functions to load algorithms at runtime
313 * Prior to calling us, the 50MHz clock frequency and routing
314 * must have been set up for the PSC indicated by the adapter.
315 */
316static int __devinit
317i2c_au1550_probe(struct platform_device *pdev)
318{
319 struct i2c_au1550_data *priv;
320 struct resource *r;
321 int ret;
322
323 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
324 if (!r) {
325 ret = -ENODEV;
326 goto out;
327 }
328
329 priv = kzalloc(sizeof(struct i2c_au1550_data), GFP_KERNEL);
330 if (!priv) {
331 ret = -ENOMEM;
332 goto out;
333 }
334
Linus Walleijc6ffdde2009-06-14 00:20:36 +0200335 priv->ioarea = request_mem_region(r->start, resource_size(r),
Manuel Laussf09f71b2008-07-14 22:38:34 +0200336 pdev->name);
337 if (!priv->ioarea) {
338 ret = -EBUSY;
339 goto out_mem;
340 }
341
Manuel Laussc5de6462011-10-22 13:34:36 +0200342 priv->psc_base = ioremap(r->start, resource_size(r));
343 if (!priv->psc_base) {
344 ret = -EIO;
345 goto out_map;
346 }
Manuel Laussf09f71b2008-07-14 22:38:34 +0200347 priv->xfer_timeout = 200;
Manuel Laussf09f71b2008-07-14 22:38:34 +0200348
Manuel Laussf09f71b2008-07-14 22:38:34 +0200349 priv->adap.nr = pdev->id;
350 priv->adap.algo = &au1550_algo;
351 priv->adap.algo_data = priv;
352 priv->adap.dev.parent = &pdev->dev;
353 strlcpy(priv->adap.name, "Au1xxx PSC I2C", sizeof(priv->adap.name));
354
Manuel Laussc5de6462011-10-22 13:34:36 +0200355 /* Now, set up the PSC for SMBus PIO mode. */
Manuel Laussf09f71b2008-07-14 22:38:34 +0200356 i2c_au1550_setup(priv);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357
Manuel Lauss8b798c42008-01-27 18:14:52 +0100358 ret = i2c_add_numbered_adapter(&priv->adap);
359 if (ret == 0) {
360 platform_set_drvdata(pdev, priv);
361 return 0;
362 }
363
Manuel Laussf09f71b2008-07-14 22:38:34 +0200364 i2c_au1550_disable(priv);
Manuel Laussc5de6462011-10-22 13:34:36 +0200365 iounmap(priv->psc_base);
366out_map:
Manuel Lauss8b798c42008-01-27 18:14:52 +0100367 release_resource(priv->ioarea);
368 kfree(priv->ioarea);
369out_mem:
370 kfree(priv);
371out:
372 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373}
374
Manuel Laussc5de6462011-10-22 13:34:36 +0200375static int __devexit i2c_au1550_remove(struct platform_device *pdev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376{
Manuel Lauss8b798c42008-01-27 18:14:52 +0100377 struct i2c_au1550_data *priv = platform_get_drvdata(pdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378
Manuel Lauss8b798c42008-01-27 18:14:52 +0100379 platform_set_drvdata(pdev, NULL);
380 i2c_del_adapter(&priv->adap);
Manuel Laussf09f71b2008-07-14 22:38:34 +0200381 i2c_au1550_disable(priv);
Manuel Laussc5de6462011-10-22 13:34:36 +0200382 iounmap(priv->psc_base);
Manuel Lauss8b798c42008-01-27 18:14:52 +0100383 release_resource(priv->ioarea);
384 kfree(priv->ioarea);
385 kfree(priv);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700386 return 0;
387}
388
Manuel Laussf09f71b2008-07-14 22:38:34 +0200389#ifdef CONFIG_PM
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390static int
Manuel Lauss8b798c42008-01-27 18:14:52 +0100391i2c_au1550_suspend(struct platform_device *pdev, pm_message_t state)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700392{
Manuel Lauss8b798c42008-01-27 18:14:52 +0100393 struct i2c_au1550_data *priv = platform_get_drvdata(pdev);
Manuel Lauss8b798c42008-01-27 18:14:52 +0100394
Manuel Laussf09f71b2008-07-14 22:38:34 +0200395 i2c_au1550_disable(priv);
396
Linus Torvalds1da177e2005-04-16 15:20:36 -0700397 return 0;
398}
399
Manuel Lauss8b798c42008-01-27 18:14:52 +0100400static int
401i2c_au1550_resume(struct platform_device *pdev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402{
Manuel Lauss8b798c42008-01-27 18:14:52 +0100403 struct i2c_au1550_data *priv = platform_get_drvdata(pdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404
Manuel Laussf09f71b2008-07-14 22:38:34 +0200405 i2c_au1550_setup(priv);
406
Manuel Lauss8b798c42008-01-27 18:14:52 +0100407 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408}
Manuel Laussf09f71b2008-07-14 22:38:34 +0200409#else
410#define i2c_au1550_suspend NULL
411#define i2c_au1550_resume NULL
412#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413
Manuel Lauss8b798c42008-01-27 18:14:52 +0100414static struct platform_driver au1xpsc_smbus_driver = {
415 .driver = {
416 .name = "au1xpsc_smbus",
417 .owner = THIS_MODULE,
418 },
419 .probe = i2c_au1550_probe,
420 .remove = __devexit_p(i2c_au1550_remove),
421 .suspend = i2c_au1550_suspend,
422 .resume = i2c_au1550_resume,
423};
424
Manuel Laussc5de6462011-10-22 13:34:36 +0200425static int __init i2c_au1550_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426{
Manuel Lauss8b798c42008-01-27 18:14:52 +0100427 return platform_driver_register(&au1xpsc_smbus_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700428}
429
Manuel Laussc5de6462011-10-22 13:34:36 +0200430static void __exit i2c_au1550_exit(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431{
Manuel Lauss8b798c42008-01-27 18:14:52 +0100432 platform_driver_unregister(&au1xpsc_smbus_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433}
434
435MODULE_AUTHOR("Dan Malek, Embedded Edge, LLC.");
436MODULE_DESCRIPTION("SMBus adapter Alchemy pb1550");
437MODULE_LICENSE("GPL");
Kay Sieversadd8eda2008-04-22 22:16:49 +0200438MODULE_ALIAS("platform:au1xpsc_smbus");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439
440module_init (i2c_au1550_init);
441module_exit (i2c_au1550_exit);