dev-i2c2.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* linux/arch/arm/plat-s3c/dev-i2c2.c
  2. *
  3. * Copyright (c) 2010 Samsung Electronics Co., Ltd.
  4. * http://www.samsung.com/
  5. *
  6. * S3C series device definition for i2c device 2
  7. *
  8. * Based on plat-samsung/dev-i2c0.c
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. */
  14. #include <linux/gfp.h>
  15. #include <linux/kernel.h>
  16. #include <linux/string.h>
  17. #include <linux/platform_device.h>
  18. #include <mach/irqs.h>
  19. #include <mach/map.h>
  20. #include <plat/regs-iic.h>
  21. #include <plat/iic.h>
  22. #include <plat/devs.h>
  23. #include <plat/cpu.h>
  24. static struct resource s3c_i2c_resource[] = {
  25. [0] = {
  26. .start = S3C_PA_IIC2,
  27. .end = S3C_PA_IIC2 + SZ_4K - 1,
  28. .flags = IORESOURCE_MEM,
  29. },
  30. [1] = {
  31. .start = IRQ_IIC2,
  32. .end = IRQ_IIC2,
  33. .flags = IORESOURCE_IRQ,
  34. },
  35. };
  36. struct platform_device s3c_device_i2c2 = {
  37. .name = "s3c2410-i2c",
  38. .id = 2,
  39. .num_resources = ARRAY_SIZE(s3c_i2c_resource),
  40. .resource = s3c_i2c_resource,
  41. };
  42. static struct s3c2410_platform_i2c default_i2c_data2 __initdata = {
  43. .flags = 0,
  44. .bus_num = 2,
  45. .slave_addr = 0x10,
  46. .frequency = 100*1000,
  47. .sda_delay = 100,
  48. };
  49. void __init s3c_i2c2_set_platdata(struct s3c2410_platform_i2c *pd)
  50. {
  51. struct s3c2410_platform_i2c *npd;
  52. if (!pd)
  53. pd = &default_i2c_data2;
  54. npd = kmemdup(pd, sizeof(struct s3c2410_platform_i2c), GFP_KERNEL);
  55. if (!npd)
  56. printk(KERN_ERR "%s: no memory for platform data\n", __func__);
  57. else if (!npd->cfg_gpio)
  58. npd->cfg_gpio = s3c_i2c2_cfg_gpio;
  59. s3c_device_i2c2.dev.platform_data = npd;
  60. }