1ad7d142fSJuergen Fitschen // SPDX-License-Identifier: GPL-2.0 2ad7d142fSJuergen Fitschen /* 3ad7d142fSJuergen Fitschen * i2c Support for Atmel's AT91 Two-Wire Interface (TWI) 4ad7d142fSJuergen Fitschen * 5ad7d142fSJuergen Fitschen * Copyright (C) 2011 Weinmann Medical GmbH 6ad7d142fSJuergen Fitschen * Author: Nikolaus Voss <n.voss@weinmann.de> 7ad7d142fSJuergen Fitschen * 8ad7d142fSJuergen Fitschen * Evolved from original work by: 9ad7d142fSJuergen Fitschen * Copyright (C) 2004 Rick Bronson 10ad7d142fSJuergen Fitschen * Converted to 2.6 by Andrew Victor <andrew@sanpeople.com> 11ad7d142fSJuergen Fitschen * 12ad7d142fSJuergen Fitschen * Borrowed heavily from original work by: 13ad7d142fSJuergen Fitschen * Copyright (C) 2000 Philip Edelbrock <phil@stimpy.netroedge.com> 14ad7d142fSJuergen Fitschen */ 15ad7d142fSJuergen Fitschen 16ad7d142fSJuergen Fitschen #include <linux/clk.h> 17ad7d142fSJuergen Fitschen #include <linux/err.h> 18ad7d142fSJuergen Fitschen #include <linux/i2c.h> 19ad7d142fSJuergen Fitschen #include <linux/io.h> 20ad7d142fSJuergen Fitschen #include <linux/module.h> 21ad7d142fSJuergen Fitschen #include <linux/of.h> 22ad7d142fSJuergen Fitschen #include <linux/of_device.h> 23ad7d142fSJuergen Fitschen #include <linux/platform_device.h> 24ad7d142fSJuergen Fitschen #include <linux/pm_runtime.h> 25ad7d142fSJuergen Fitschen #include <linux/pinctrl/consumer.h> 26ad7d142fSJuergen Fitschen 27ad7d142fSJuergen Fitschen #include "i2c-at91.h" 28ad7d142fSJuergen Fitschen 29ad7d142fSJuergen Fitschen unsigned at91_twi_read(struct at91_twi_dev *dev, unsigned reg) 30ad7d142fSJuergen Fitschen { 31ad7d142fSJuergen Fitschen return readl_relaxed(dev->base + reg); 32ad7d142fSJuergen Fitschen } 33ad7d142fSJuergen Fitschen 34ad7d142fSJuergen Fitschen void at91_twi_write(struct at91_twi_dev *dev, unsigned reg, unsigned val) 35ad7d142fSJuergen Fitschen { 36ad7d142fSJuergen Fitschen writel_relaxed(val, dev->base + reg); 37ad7d142fSJuergen Fitschen } 38ad7d142fSJuergen Fitschen 39ad7d142fSJuergen Fitschen void at91_disable_twi_interrupts(struct at91_twi_dev *dev) 40ad7d142fSJuergen Fitschen { 41ad7d142fSJuergen Fitschen at91_twi_write(dev, AT91_TWI_IDR, AT91_TWI_INT_MASK); 42ad7d142fSJuergen Fitschen } 43ad7d142fSJuergen Fitschen 44ad7d142fSJuergen Fitschen void at91_twi_irq_save(struct at91_twi_dev *dev) 45ad7d142fSJuergen Fitschen { 46ad7d142fSJuergen Fitschen dev->imr = at91_twi_read(dev, AT91_TWI_IMR) & AT91_TWI_INT_MASK; 47ad7d142fSJuergen Fitschen at91_disable_twi_interrupts(dev); 48ad7d142fSJuergen Fitschen } 49ad7d142fSJuergen Fitschen 50ad7d142fSJuergen Fitschen void at91_twi_irq_restore(struct at91_twi_dev *dev) 51ad7d142fSJuergen Fitschen { 52ad7d142fSJuergen Fitschen at91_twi_write(dev, AT91_TWI_IER, dev->imr); 53ad7d142fSJuergen Fitschen } 54ad7d142fSJuergen Fitschen 55ad7d142fSJuergen Fitschen void at91_init_twi_bus(struct at91_twi_dev *dev) 56ad7d142fSJuergen Fitschen { 57ad7d142fSJuergen Fitschen at91_disable_twi_interrupts(dev); 58ad7d142fSJuergen Fitschen at91_twi_write(dev, AT91_TWI_CR, AT91_TWI_SWRST); 599d3ca54bSJuergen Fitschen if (dev->slave_detected) 609d3ca54bSJuergen Fitschen at91_init_twi_bus_slave(dev); 619d3ca54bSJuergen Fitschen else 62ad7d142fSJuergen Fitschen at91_init_twi_bus_master(dev); 63ad7d142fSJuergen Fitschen } 64ad7d142fSJuergen Fitschen 65ad7d142fSJuergen Fitschen static struct at91_twi_pdata at91rm9200_config = { 66ad7d142fSJuergen Fitschen .clk_max_div = 5, 67ad7d142fSJuergen Fitschen .clk_offset = 3, 68ad7d142fSJuergen Fitschen .has_unre_flag = true, 69ad7d142fSJuergen Fitschen }; 70ad7d142fSJuergen Fitschen 71ad7d142fSJuergen Fitschen static struct at91_twi_pdata at91sam9261_config = { 72ad7d142fSJuergen Fitschen .clk_max_div = 5, 73ad7d142fSJuergen Fitschen .clk_offset = 4, 74ad7d142fSJuergen Fitschen }; 75ad7d142fSJuergen Fitschen 76ad7d142fSJuergen Fitschen static struct at91_twi_pdata at91sam9260_config = { 77ad7d142fSJuergen Fitschen .clk_max_div = 7, 78ad7d142fSJuergen Fitschen .clk_offset = 4, 79ad7d142fSJuergen Fitschen }; 80ad7d142fSJuergen Fitschen 81ad7d142fSJuergen Fitschen static struct at91_twi_pdata at91sam9g20_config = { 82ad7d142fSJuergen Fitschen .clk_max_div = 7, 83ad7d142fSJuergen Fitschen .clk_offset = 4, 84ad7d142fSJuergen Fitschen }; 85ad7d142fSJuergen Fitschen 86ad7d142fSJuergen Fitschen static struct at91_twi_pdata at91sam9g10_config = { 87ad7d142fSJuergen Fitschen .clk_max_div = 7, 88ad7d142fSJuergen Fitschen .clk_offset = 4, 89ad7d142fSJuergen Fitschen }; 90ad7d142fSJuergen Fitschen 91ad7d142fSJuergen Fitschen static const struct platform_device_id at91_twi_devtypes[] = { 92ad7d142fSJuergen Fitschen { 93ad7d142fSJuergen Fitschen .name = "i2c-at91rm9200", 94ad7d142fSJuergen Fitschen .driver_data = (unsigned long) &at91rm9200_config, 95ad7d142fSJuergen Fitschen }, { 96ad7d142fSJuergen Fitschen .name = "i2c-at91sam9261", 97ad7d142fSJuergen Fitschen .driver_data = (unsigned long) &at91sam9261_config, 98ad7d142fSJuergen Fitschen }, { 99ad7d142fSJuergen Fitschen .name = "i2c-at91sam9260", 100ad7d142fSJuergen Fitschen .driver_data = (unsigned long) &at91sam9260_config, 101ad7d142fSJuergen Fitschen }, { 102ad7d142fSJuergen Fitschen .name = "i2c-at91sam9g20", 103ad7d142fSJuergen Fitschen .driver_data = (unsigned long) &at91sam9g20_config, 104ad7d142fSJuergen Fitschen }, { 105ad7d142fSJuergen Fitschen .name = "i2c-at91sam9g10", 106ad7d142fSJuergen Fitschen .driver_data = (unsigned long) &at91sam9g10_config, 107ad7d142fSJuergen Fitschen }, { 108ad7d142fSJuergen Fitschen /* sentinel */ 109ad7d142fSJuergen Fitschen } 110ad7d142fSJuergen Fitschen }; 111ad7d142fSJuergen Fitschen 112ad7d142fSJuergen Fitschen #if defined(CONFIG_OF) 113ad7d142fSJuergen Fitschen static struct at91_twi_pdata at91sam9x5_config = { 114ad7d142fSJuergen Fitschen .clk_max_div = 7, 115ad7d142fSJuergen Fitschen .clk_offset = 4, 116ad7d142fSJuergen Fitschen }; 117ad7d142fSJuergen Fitschen 118ad7d142fSJuergen Fitschen static struct at91_twi_pdata sama5d4_config = { 119ad7d142fSJuergen Fitschen .clk_max_div = 7, 120ad7d142fSJuergen Fitschen .clk_offset = 4, 121ad7d142fSJuergen Fitschen .has_hold_field = true, 1222989b459SEugen Hristev .has_dig_filtr = true, 123ad7d142fSJuergen Fitschen }; 124ad7d142fSJuergen Fitschen 125ad7d142fSJuergen Fitschen static struct at91_twi_pdata sama5d2_config = { 126ad7d142fSJuergen Fitschen .clk_max_div = 7, 127b1ac6704SMichał Mirosław .clk_offset = 3, 128ad7d142fSJuergen Fitschen .has_unre_flag = true, 129ad7d142fSJuergen Fitschen .has_alt_cmd = true, 130ad7d142fSJuergen Fitschen .has_hold_field = true, 1312989b459SEugen Hristev .has_dig_filtr = true, 1322be357afSEugen Hristev .has_adv_dig_filtr = true, 133dda96713SEugen Hristev .has_ana_filtr = true, 13473371d5fSCodrin Ciubotariu .has_clear_cmd = false, /* due to errata, CLEAR cmd is not working */ 135ad7d142fSJuergen Fitschen }; 136ad7d142fSJuergen Fitschen 137b0027792SEugen Hristev static struct at91_twi_pdata sam9x60_config = { 138b0027792SEugen Hristev .clk_max_div = 7, 139b7169a57SEugen Hristev .clk_offset = 3, 140b0027792SEugen Hristev .has_unre_flag = true, 141b0027792SEugen Hristev .has_alt_cmd = true, 142b0027792SEugen Hristev .has_hold_field = true, 1432989b459SEugen Hristev .has_dig_filtr = true, 1442be357afSEugen Hristev .has_adv_dig_filtr = true, 145dda96713SEugen Hristev .has_ana_filtr = true, 14673371d5fSCodrin Ciubotariu .has_clear_cmd = true, 147b0027792SEugen Hristev }; 148b0027792SEugen Hristev 149ad7d142fSJuergen Fitschen static const struct of_device_id atmel_twi_dt_ids[] = { 150ad7d142fSJuergen Fitschen { 151ad7d142fSJuergen Fitschen .compatible = "atmel,at91rm9200-i2c", 152ad7d142fSJuergen Fitschen .data = &at91rm9200_config, 153ad7d142fSJuergen Fitschen }, { 154ad7d142fSJuergen Fitschen .compatible = "atmel,at91sam9260-i2c", 155ad7d142fSJuergen Fitschen .data = &at91sam9260_config, 156ad7d142fSJuergen Fitschen }, { 157ad7d142fSJuergen Fitschen .compatible = "atmel,at91sam9261-i2c", 158ad7d142fSJuergen Fitschen .data = &at91sam9261_config, 159ad7d142fSJuergen Fitschen }, { 160ad7d142fSJuergen Fitschen .compatible = "atmel,at91sam9g20-i2c", 161ad7d142fSJuergen Fitschen .data = &at91sam9g20_config, 162ad7d142fSJuergen Fitschen }, { 163ad7d142fSJuergen Fitschen .compatible = "atmel,at91sam9g10-i2c", 164ad7d142fSJuergen Fitschen .data = &at91sam9g10_config, 165ad7d142fSJuergen Fitschen }, { 166ad7d142fSJuergen Fitschen .compatible = "atmel,at91sam9x5-i2c", 167ad7d142fSJuergen Fitschen .data = &at91sam9x5_config, 168ad7d142fSJuergen Fitschen }, { 169ad7d142fSJuergen Fitschen .compatible = "atmel,sama5d4-i2c", 170ad7d142fSJuergen Fitschen .data = &sama5d4_config, 171ad7d142fSJuergen Fitschen }, { 172ad7d142fSJuergen Fitschen .compatible = "atmel,sama5d2-i2c", 173ad7d142fSJuergen Fitschen .data = &sama5d2_config, 174ad7d142fSJuergen Fitschen }, { 175b0027792SEugen Hristev .compatible = "microchip,sam9x60-i2c", 176b0027792SEugen Hristev .data = &sam9x60_config, 177b0027792SEugen Hristev }, { 178ad7d142fSJuergen Fitschen /* sentinel */ 179ad7d142fSJuergen Fitschen } 180ad7d142fSJuergen Fitschen }; 181ad7d142fSJuergen Fitschen MODULE_DEVICE_TABLE(of, atmel_twi_dt_ids); 182ad7d142fSJuergen Fitschen #endif 183ad7d142fSJuergen Fitschen 184ad7d142fSJuergen Fitschen static struct at91_twi_pdata *at91_twi_get_driver_data( 185ad7d142fSJuergen Fitschen struct platform_device *pdev) 186ad7d142fSJuergen Fitschen { 187ad7d142fSJuergen Fitschen if (pdev->dev.of_node) { 188ad7d142fSJuergen Fitschen const struct of_device_id *match; 189ad7d142fSJuergen Fitschen match = of_match_node(atmel_twi_dt_ids, pdev->dev.of_node); 190ad7d142fSJuergen Fitschen if (!match) 191ad7d142fSJuergen Fitschen return NULL; 192ad7d142fSJuergen Fitschen return (struct at91_twi_pdata *)match->data; 193ad7d142fSJuergen Fitschen } 194ad7d142fSJuergen Fitschen return (struct at91_twi_pdata *) platform_get_device_id(pdev)->driver_data; 195ad7d142fSJuergen Fitschen } 196ad7d142fSJuergen Fitschen 197ad7d142fSJuergen Fitschen static int at91_twi_probe(struct platform_device *pdev) 198ad7d142fSJuergen Fitschen { 199ad7d142fSJuergen Fitschen struct at91_twi_dev *dev; 200ad7d142fSJuergen Fitschen struct resource *mem; 201ad7d142fSJuergen Fitschen int rc; 202ad7d142fSJuergen Fitschen u32 phy_addr; 203ad7d142fSJuergen Fitschen 204ad7d142fSJuergen Fitschen dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL); 205ad7d142fSJuergen Fitschen if (!dev) 206ad7d142fSJuergen Fitschen return -ENOMEM; 207ad7d142fSJuergen Fitschen 208ad7d142fSJuergen Fitschen dev->dev = &pdev->dev; 209ad7d142fSJuergen Fitschen 210ad7d142fSJuergen Fitschen mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 211ad7d142fSJuergen Fitschen if (!mem) 212ad7d142fSJuergen Fitschen return -ENODEV; 213ad7d142fSJuergen Fitschen phy_addr = mem->start; 214ad7d142fSJuergen Fitschen 215ad7d142fSJuergen Fitschen dev->pdata = at91_twi_get_driver_data(pdev); 216ad7d142fSJuergen Fitschen if (!dev->pdata) 217ad7d142fSJuergen Fitschen return -ENODEV; 218ad7d142fSJuergen Fitschen 219ad7d142fSJuergen Fitschen dev->base = devm_ioremap_resource(&pdev->dev, mem); 220ad7d142fSJuergen Fitschen if (IS_ERR(dev->base)) 221ad7d142fSJuergen Fitschen return PTR_ERR(dev->base); 222ad7d142fSJuergen Fitschen 223ad7d142fSJuergen Fitschen dev->irq = platform_get_irq(pdev, 0); 224ad7d142fSJuergen Fitschen if (dev->irq < 0) 225ad7d142fSJuergen Fitschen return dev->irq; 226ad7d142fSJuergen Fitschen 227ad7d142fSJuergen Fitschen platform_set_drvdata(pdev, dev); 228ad7d142fSJuergen Fitschen 229ad7d142fSJuergen Fitschen dev->clk = devm_clk_get(dev->dev, NULL); 230ad7d142fSJuergen Fitschen if (IS_ERR(dev->clk)) { 231ad7d142fSJuergen Fitschen dev_err(dev->dev, "no clock defined\n"); 232ad7d142fSJuergen Fitschen return -ENODEV; 233ad7d142fSJuergen Fitschen } 234ad7d142fSJuergen Fitschen clk_prepare_enable(dev->clk); 235ad7d142fSJuergen Fitschen 236ad7d142fSJuergen Fitschen snprintf(dev->adapter.name, sizeof(dev->adapter.name), "AT91"); 237ad7d142fSJuergen Fitschen i2c_set_adapdata(&dev->adapter, dev); 238ad7d142fSJuergen Fitschen dev->adapter.owner = THIS_MODULE; 239ad7d142fSJuergen Fitschen dev->adapter.class = I2C_CLASS_DEPRECATED; 240ad7d142fSJuergen Fitschen dev->adapter.dev.parent = dev->dev; 241ad7d142fSJuergen Fitschen dev->adapter.nr = pdev->id; 242ad7d142fSJuergen Fitschen dev->adapter.timeout = AT91_I2C_TIMEOUT; 243ad7d142fSJuergen Fitschen dev->adapter.dev.of_node = pdev->dev.of_node; 244ad7d142fSJuergen Fitschen 2459d3ca54bSJuergen Fitschen dev->slave_detected = i2c_detect_slave_mode(&pdev->dev); 2469d3ca54bSJuergen Fitschen 2479d3ca54bSJuergen Fitschen if (dev->slave_detected) 2489d3ca54bSJuergen Fitschen rc = at91_twi_probe_slave(pdev, phy_addr, dev); 2499d3ca54bSJuergen Fitschen else 250ad7d142fSJuergen Fitschen rc = at91_twi_probe_master(pdev, phy_addr, dev); 251ad7d142fSJuergen Fitschen if (rc) 252ad7d142fSJuergen Fitschen return rc; 253ad7d142fSJuergen Fitschen 254ad7d142fSJuergen Fitschen at91_init_twi_bus(dev); 255ad7d142fSJuergen Fitschen 256ad7d142fSJuergen Fitschen pm_runtime_set_autosuspend_delay(dev->dev, AUTOSUSPEND_TIMEOUT); 257ad7d142fSJuergen Fitschen pm_runtime_use_autosuspend(dev->dev); 258ad7d142fSJuergen Fitschen pm_runtime_set_active(dev->dev); 259ad7d142fSJuergen Fitschen pm_runtime_enable(dev->dev); 260ad7d142fSJuergen Fitschen 261ad7d142fSJuergen Fitschen rc = i2c_add_numbered_adapter(&dev->adapter); 262ad7d142fSJuergen Fitschen if (rc) { 263ad7d142fSJuergen Fitschen clk_disable_unprepare(dev->clk); 264ad7d142fSJuergen Fitschen 265ad7d142fSJuergen Fitschen pm_runtime_disable(dev->dev); 266ad7d142fSJuergen Fitschen pm_runtime_set_suspended(dev->dev); 267ad7d142fSJuergen Fitschen 268ad7d142fSJuergen Fitschen return rc; 269ad7d142fSJuergen Fitschen } 270ad7d142fSJuergen Fitschen 271ad7d142fSJuergen Fitschen dev_info(dev->dev, "AT91 i2c bus driver (hw version: %#x).\n", 272ad7d142fSJuergen Fitschen at91_twi_read(dev, AT91_TWI_VER)); 273ad7d142fSJuergen Fitschen return 0; 274ad7d142fSJuergen Fitschen } 275ad7d142fSJuergen Fitschen 276ad7d142fSJuergen Fitschen static int at91_twi_remove(struct platform_device *pdev) 277ad7d142fSJuergen Fitschen { 278ad7d142fSJuergen Fitschen struct at91_twi_dev *dev = platform_get_drvdata(pdev); 279ad7d142fSJuergen Fitschen 280ad7d142fSJuergen Fitschen i2c_del_adapter(&dev->adapter); 281ad7d142fSJuergen Fitschen clk_disable_unprepare(dev->clk); 282ad7d142fSJuergen Fitschen 283ad7d142fSJuergen Fitschen pm_runtime_disable(dev->dev); 284ad7d142fSJuergen Fitschen pm_runtime_set_suspended(dev->dev); 285ad7d142fSJuergen Fitschen 286ad7d142fSJuergen Fitschen return 0; 287ad7d142fSJuergen Fitschen } 288ad7d142fSJuergen Fitschen 289*dab4b0e8SClaudiu Beznea static int __maybe_unused at91_twi_runtime_suspend(struct device *dev) 290ad7d142fSJuergen Fitschen { 291ad7d142fSJuergen Fitschen struct at91_twi_dev *twi_dev = dev_get_drvdata(dev); 292ad7d142fSJuergen Fitschen 293ad7d142fSJuergen Fitschen clk_disable_unprepare(twi_dev->clk); 294ad7d142fSJuergen Fitschen 295ad7d142fSJuergen Fitschen pinctrl_pm_select_sleep_state(dev); 296ad7d142fSJuergen Fitschen 297ad7d142fSJuergen Fitschen return 0; 298ad7d142fSJuergen Fitschen } 299ad7d142fSJuergen Fitschen 300*dab4b0e8SClaudiu Beznea static int __maybe_unused at91_twi_runtime_resume(struct device *dev) 301ad7d142fSJuergen Fitschen { 302ad7d142fSJuergen Fitschen struct at91_twi_dev *twi_dev = dev_get_drvdata(dev); 303ad7d142fSJuergen Fitschen 304ad7d142fSJuergen Fitschen pinctrl_pm_select_default_state(dev); 305ad7d142fSJuergen Fitschen 306ad7d142fSJuergen Fitschen return clk_prepare_enable(twi_dev->clk); 307ad7d142fSJuergen Fitschen } 308ad7d142fSJuergen Fitschen 309*dab4b0e8SClaudiu Beznea static int __maybe_unused at91_twi_suspend_noirq(struct device *dev) 310ad7d142fSJuergen Fitschen { 311ad7d142fSJuergen Fitschen if (!pm_runtime_status_suspended(dev)) 312ad7d142fSJuergen Fitschen at91_twi_runtime_suspend(dev); 313ad7d142fSJuergen Fitschen 314ad7d142fSJuergen Fitschen return 0; 315ad7d142fSJuergen Fitschen } 316ad7d142fSJuergen Fitschen 317*dab4b0e8SClaudiu Beznea static int __maybe_unused at91_twi_resume_noirq(struct device *dev) 318ad7d142fSJuergen Fitschen { 319ad7d142fSJuergen Fitschen struct at91_twi_dev *twi_dev = dev_get_drvdata(dev); 320ad7d142fSJuergen Fitschen int ret; 321ad7d142fSJuergen Fitschen 322ad7d142fSJuergen Fitschen if (!pm_runtime_status_suspended(dev)) { 323ad7d142fSJuergen Fitschen ret = at91_twi_runtime_resume(dev); 324ad7d142fSJuergen Fitschen if (ret) 325ad7d142fSJuergen Fitschen return ret; 326ad7d142fSJuergen Fitschen } 327ad7d142fSJuergen Fitschen 328ad7d142fSJuergen Fitschen pm_runtime_mark_last_busy(dev); 329ad7d142fSJuergen Fitschen pm_request_autosuspend(dev); 330ad7d142fSJuergen Fitschen 331ad7d142fSJuergen Fitschen at91_init_twi_bus(twi_dev); 332ad7d142fSJuergen Fitschen 333ad7d142fSJuergen Fitschen return 0; 334ad7d142fSJuergen Fitschen } 335ad7d142fSJuergen Fitschen 336ad7d142fSJuergen Fitschen static const struct dev_pm_ops at91_twi_pm = { 337ad7d142fSJuergen Fitschen .suspend_noirq = at91_twi_suspend_noirq, 338ad7d142fSJuergen Fitschen .resume_noirq = at91_twi_resume_noirq, 339ad7d142fSJuergen Fitschen .runtime_suspend = at91_twi_runtime_suspend, 340ad7d142fSJuergen Fitschen .runtime_resume = at91_twi_runtime_resume, 341ad7d142fSJuergen Fitschen }; 342ad7d142fSJuergen Fitschen 343ad7d142fSJuergen Fitschen static struct platform_driver at91_twi_driver = { 344ad7d142fSJuergen Fitschen .probe = at91_twi_probe, 345ad7d142fSJuergen Fitschen .remove = at91_twi_remove, 346ad7d142fSJuergen Fitschen .id_table = at91_twi_devtypes, 347ad7d142fSJuergen Fitschen .driver = { 348ad7d142fSJuergen Fitschen .name = "at91_i2c", 349ad7d142fSJuergen Fitschen .of_match_table = of_match_ptr(atmel_twi_dt_ids), 350*dab4b0e8SClaudiu Beznea .pm = pm_ptr(&at91_twi_pm), 351ad7d142fSJuergen Fitschen }, 352ad7d142fSJuergen Fitschen }; 353ad7d142fSJuergen Fitschen 354ad7d142fSJuergen Fitschen static int __init at91_twi_init(void) 355ad7d142fSJuergen Fitschen { 356ad7d142fSJuergen Fitschen return platform_driver_register(&at91_twi_driver); 357ad7d142fSJuergen Fitschen } 358ad7d142fSJuergen Fitschen 359ad7d142fSJuergen Fitschen static void __exit at91_twi_exit(void) 360ad7d142fSJuergen Fitschen { 361ad7d142fSJuergen Fitschen platform_driver_unregister(&at91_twi_driver); 362ad7d142fSJuergen Fitschen } 363ad7d142fSJuergen Fitschen 364ad7d142fSJuergen Fitschen subsys_initcall(at91_twi_init); 365ad7d142fSJuergen Fitschen module_exit(at91_twi_exit); 366ad7d142fSJuergen Fitschen 367ad7d142fSJuergen Fitschen MODULE_AUTHOR("Nikolaus Voss <n.voss@weinmann.de>"); 368ad7d142fSJuergen Fitschen MODULE_DESCRIPTION("I2C (TWI) driver for Atmel AT91"); 369ad7d142fSJuergen Fitschen MODULE_LICENSE("GPL"); 370ad7d142fSJuergen Fitschen MODULE_ALIAS("platform:at91_i2c"); 371