Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * arch/arm/plat-iop/i2c.c
0004  *
0005  * Author: Nicolas Pitre <nico@cam.org>
0006  * Copyright (C) 2001 MontaVista Software, Inc.
0007  * Copyright (C) 2004 Intel Corporation.
0008  */
0009 
0010 #include <linux/mm.h>
0011 #include <linux/init.h>
0012 #include <linux/major.h>
0013 #include <linux/fs.h>
0014 #include <linux/platform_device.h>
0015 #include <linux/serial.h>
0016 #include <linux/tty.h>
0017 #include <linux/serial_core.h>
0018 #include <linux/io.h>
0019 #include <linux/gpio/machine.h>
0020 #include <asm/page.h>
0021 #include <asm/mach/map.h>
0022 #include <asm/setup.h>
0023 #include <asm/memory.h>
0024 #include <asm/mach/arch.h>
0025 
0026 #include "hardware.h"
0027 #include "iop3xx.h"
0028 #include "irqs.h"
0029 
0030 /*
0031  * Each of the I2C busses have corresponding GPIO lines, and the driver
0032  * need to access these directly to drive the bus low at times.
0033  */
0034 
0035 struct gpiod_lookup_table iop3xx_i2c0_gpio_lookup = {
0036     .dev_id = "IOP3xx-I2C.0",
0037     .table = {
0038         GPIO_LOOKUP("gpio-iop", 7, "scl", GPIO_ACTIVE_HIGH),
0039         GPIO_LOOKUP("gpio-iop", 6, "sda", GPIO_ACTIVE_HIGH),
0040         { }
0041     },
0042 };
0043 
0044 struct gpiod_lookup_table iop3xx_i2c1_gpio_lookup = {
0045     .dev_id = "IOP3xx-I2C.1",
0046     .table = {
0047         GPIO_LOOKUP("gpio-iop", 5, "scl", GPIO_ACTIVE_HIGH),
0048         GPIO_LOOKUP("gpio-iop", 4, "sda", GPIO_ACTIVE_HIGH),
0049         { }
0050     },
0051 };
0052 
0053 static struct resource iop3xx_i2c0_resources[] = {
0054     [0] = {
0055         .start  = 0xfffff680,
0056         .end    = 0xfffff697,
0057         .flags  = IORESOURCE_MEM,
0058     },
0059     [1] = {
0060         .start  = IRQ_IOP32X_I2C_0,
0061         .end    = IRQ_IOP32X_I2C_0,
0062         .flags  = IORESOURCE_IRQ,
0063     },
0064 };
0065 
0066 struct platform_device iop3xx_i2c0_device = {
0067     .name       = "IOP3xx-I2C",
0068     .id     = 0,
0069     .num_resources  = 2,
0070     .resource   = iop3xx_i2c0_resources,
0071 };
0072 
0073 
0074 static struct resource iop3xx_i2c1_resources[] = {
0075     [0] = {
0076         .start  = 0xfffff6a0,
0077         .end    = 0xfffff6b7,
0078         .flags  = IORESOURCE_MEM,
0079     },
0080     [1] = {
0081         .start  = IRQ_IOP32X_I2C_1,
0082         .end    = IRQ_IOP32X_I2C_1,
0083         .flags  = IORESOURCE_IRQ,
0084     }
0085 };
0086 
0087 struct platform_device iop3xx_i2c1_device = {
0088     .name       = "IOP3xx-I2C",
0089     .id     = 1,
0090     .num_resources  = 2,
0091     .resource   = iop3xx_i2c1_resources,
0092 };