static int __init i2c_davinci_init(void) { int status; struct device *dev = NULL; DEB0("%s %s", __TIME__, __DATE__); DEB1("i2c_davinci_init()\n"); davinci_i2c_fix_ths7353_lockup( ); #if 0 if (i2c_davinci_busFreq > 200) i2c_davinci_busFreq = 400; /*Fast mode */ else i2c_davinci_busFreq = 100; /*Standard mode */ #endif i2c_clock = clk_get (dev, "I2CCLK"); if (i2c_clock == NULL) return -1; clk_use (i2c_clock); clk_enable (i2c_clock); i2c_davinci_inputClock = clk_get_rate (i2c_clock); DEB1 ("IP CLOCK = %ld\n", i2c_davinci_inputClock); memset(&i2c_davinci_dev, 0, sizeof(i2c_davinci_dev)); i2c_davinci_dev.regs = (davinci_i2cregsovly)I2C_BASE; status = (int)request_region(I2C_BASE, I2C_IOSIZE, MODULE_NAME); if (!status) { i2c_err("I2C is already in use\n"); return -ENODEV; } status = request_irq(IRQ_I2C, i2c_davinci_isr, 0, MODULE_NAME, &i2c_davinci_dev); if (status) { i2c_err("failed to request I2C IRQ"); goto do_release_region; } i2c_set_adapdata(&i2c_davinci_adap, &i2c_davinci_dev); status = i2c_add_adapter(&i2c_davinci_adap); if (status) { i2c_err("failed to add adapter"); goto do_free_irq; return status; } i2c_davinci_reset(&i2c_davinci_dev); if (driver_register(&davinci_i2c_driver) != 0) printk(KERN_ERR "Driver register failed for davinci_i2c\n"); if (platform_device_register(&davinci_i2c_device) != 0) { printk(KERN_ERR "Device register failed for i2c\n"); driver_unregister(&davinci_i2c_driver); } return 0; do_free_irq: free_irq(IRQ_I2C, &i2c_davinci_dev); do_release_region: release_region(I2C_BASE, I2C_IOSIZE); return status; }
static int __init i2c_davinci_init(void) { int status; struct device *dev = NULL; DEB0("%s %s", __TIME__, __DATE__); DEB1("i2c_davinci_init()"); if (cpu_is_davinci_dm6467()) davinci_i2c_expander_op (0x3A, I2C_INT_DM646X, 0); /* * NOTE: On DaVinci EVM, the i2c bus frequency is set to 20kHz * so that the MSP430, which is doing software i2c, has * some extra processing time */ if (machine_is_davinci_evm()) i2c_davinci_busFreq = 20; else if (machine_is_davinci_dm6467_evm()) i2c_davinci_busFreq = 100; else if (i2c_davinci_busFreq > 200) i2c_davinci_busFreq = 400; /*Fast mode */ else i2c_davinci_busFreq = 100; /*Standard mode */ i2c_clock = clk_get (dev, "I2CCLK"); if (IS_ERR(i2c_clock)) return -1; clk_use (i2c_clock); clk_enable (i2c_clock); i2c_davinci_inputClock = clk_get_rate (i2c_clock); DEB1 ("IP CLOCK = %ld", i2c_davinci_inputClock); memset(&i2c_davinci_dev, 0, sizeof(i2c_davinci_dev)); init_waitqueue_head(&i2c_davinci_dev.cmd_wait); i2c_davinci_dev.regs = (davinci_i2cregsovly)I2C_BASE; status = (int)request_region(I2C_BASE, I2C_IOSIZE, MODULE_NAME); if (!status) { i2c_err("I2C is already in use\n"); return -ENODEV; } status = request_irq(IRQ_I2C, i2c_davinci_isr, 0, "i2c", &i2c_davinci_dev); if (status) { i2c_err("failed to request I2C IRQ"); goto do_release_region; } i2c_set_adapdata(&i2c_davinci_adap, &i2c_davinci_dev); status = i2c_add_adapter(&i2c_davinci_adap); if (status) { i2c_err("failed to add adapter"); goto do_free_irq; } i2c_davinci_reset(&i2c_davinci_dev); if (driver_register(&davinci_i2c_driver) != 0) printk(KERN_ERR "Driver register failed for davinci_i2c\n"); if (platform_device_register(&davinci_i2c_device) != 0) { printk(KERN_ERR "Device register failed for i2c\n"); driver_unregister(&davinci_i2c_driver); } return 0; do_free_irq: free_irq(IRQ_I2C, &i2c_davinci_dev); do_release_region: release_region(I2C_BASE, I2C_IOSIZE); return status; }