i2c.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * arch/arm/plat-iop/i2c.c
  4. *
  5. * Author: Nicolas Pitre <[email protected]>
  6. * Copyright (C) 2001 MontaVista Software, Inc.
  7. * Copyright (C) 2004 Intel Corporation.
  8. */
  9. #include <linux/mm.h>
  10. #include <linux/init.h>
  11. #include <linux/major.h>
  12. #include <linux/fs.h>
  13. #include <linux/platform_device.h>
  14. #include <linux/serial.h>
  15. #include <linux/tty.h>
  16. #include <linux/serial_core.h>
  17. #include <linux/io.h>
  18. #include <linux/gpio/machine.h>
  19. #include <asm/page.h>
  20. #include <asm/mach/map.h>
  21. #include <asm/setup.h>
  22. #include <asm/memory.h>
  23. #include <asm/mach/arch.h>
  24. #include "hardware.h"
  25. #include "iop3xx.h"
  26. #include "irqs.h"
  27. /*
  28. * Each of the I2C busses have corresponding GPIO lines, and the driver
  29. * need to access these directly to drive the bus low at times.
  30. */
  31. struct gpiod_lookup_table iop3xx_i2c0_gpio_lookup = {
  32. .dev_id = "IOP3xx-I2C.0",
  33. .table = {
  34. GPIO_LOOKUP("gpio-iop", 7, "scl", GPIO_ACTIVE_HIGH),
  35. GPIO_LOOKUP("gpio-iop", 6, "sda", GPIO_ACTIVE_HIGH),
  36. { }
  37. },
  38. };
  39. struct gpiod_lookup_table iop3xx_i2c1_gpio_lookup = {
  40. .dev_id = "IOP3xx-I2C.1",
  41. .table = {
  42. GPIO_LOOKUP("gpio-iop", 5, "scl", GPIO_ACTIVE_HIGH),
  43. GPIO_LOOKUP("gpio-iop", 4, "sda", GPIO_ACTIVE_HIGH),
  44. { }
  45. },
  46. };
  47. static struct resource iop3xx_i2c0_resources[] = {
  48. [0] = {
  49. .start = 0xfffff680,
  50. .end = 0xfffff697,
  51. .flags = IORESOURCE_MEM,
  52. },
  53. [1] = {
  54. .start = IRQ_IOP32X_I2C_0,
  55. .end = IRQ_IOP32X_I2C_0,
  56. .flags = IORESOURCE_IRQ,
  57. },
  58. };
  59. struct platform_device iop3xx_i2c0_device = {
  60. .name = "IOP3xx-I2C",
  61. .id = 0,
  62. .num_resources = 2,
  63. .resource = iop3xx_i2c0_resources,
  64. };
  65. static struct resource iop3xx_i2c1_resources[] = {
  66. [0] = {
  67. .start = 0xfffff6a0,
  68. .end = 0xfffff6b7,
  69. .flags = IORESOURCE_MEM,
  70. },
  71. [1] = {
  72. .start = IRQ_IOP32X_I2C_1,
  73. .end = IRQ_IOP32X_I2C_1,
  74. .flags = IORESOURCE_IRQ,
  75. }
  76. };
  77. struct platform_device iop3xx_i2c1_device = {
  78. .name = "IOP3xx-I2C",
  79. .id = 1,
  80. .num_resources = 2,
  81. .resource = iop3xx_i2c1_resources,
  82. };