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