18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * arch/arm/plat-iop/i2c.c
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Author: Nicolas Pitre <nico@cam.org>
68c2ecf20Sopenharmony_ci * Copyright (C) 2001 MontaVista Software, Inc.
78c2ecf20Sopenharmony_ci * Copyright (C) 2004 Intel Corporation.
88c2ecf20Sopenharmony_ci */
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#include <linux/mm.h>
118c2ecf20Sopenharmony_ci#include <linux/init.h>
128c2ecf20Sopenharmony_ci#include <linux/major.h>
138c2ecf20Sopenharmony_ci#include <linux/fs.h>
148c2ecf20Sopenharmony_ci#include <linux/platform_device.h>
158c2ecf20Sopenharmony_ci#include <linux/serial.h>
168c2ecf20Sopenharmony_ci#include <linux/tty.h>
178c2ecf20Sopenharmony_ci#include <linux/serial_core.h>
188c2ecf20Sopenharmony_ci#include <linux/io.h>
198c2ecf20Sopenharmony_ci#include <linux/gpio/machine.h>
208c2ecf20Sopenharmony_ci#include <asm/page.h>
218c2ecf20Sopenharmony_ci#include <asm/mach/map.h>
228c2ecf20Sopenharmony_ci#include <asm/setup.h>
238c2ecf20Sopenharmony_ci#include <asm/memory.h>
248c2ecf20Sopenharmony_ci#include <asm/mach/arch.h>
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci#include "hardware.h"
278c2ecf20Sopenharmony_ci#include "iop3xx.h"
288c2ecf20Sopenharmony_ci#include "irqs.h"
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci/*
318c2ecf20Sopenharmony_ci * Each of the I2C busses have corresponding GPIO lines, and the driver
328c2ecf20Sopenharmony_ci * need to access these directly to drive the bus low at times.
338c2ecf20Sopenharmony_ci */
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_cistruct gpiod_lookup_table iop3xx_i2c0_gpio_lookup = {
368c2ecf20Sopenharmony_ci	.dev_id = "IOP3xx-I2C.0",
378c2ecf20Sopenharmony_ci	.table = {
388c2ecf20Sopenharmony_ci		GPIO_LOOKUP("gpio-iop", 7, "scl", GPIO_ACTIVE_HIGH),
398c2ecf20Sopenharmony_ci		GPIO_LOOKUP("gpio-iop", 6, "sda", GPIO_ACTIVE_HIGH),
408c2ecf20Sopenharmony_ci		{ }
418c2ecf20Sopenharmony_ci	},
428c2ecf20Sopenharmony_ci};
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_cistruct gpiod_lookup_table iop3xx_i2c1_gpio_lookup = {
458c2ecf20Sopenharmony_ci	.dev_id = "IOP3xx-I2C.1",
468c2ecf20Sopenharmony_ci	.table = {
478c2ecf20Sopenharmony_ci		GPIO_LOOKUP("gpio-iop", 5, "scl", GPIO_ACTIVE_HIGH),
488c2ecf20Sopenharmony_ci		GPIO_LOOKUP("gpio-iop", 4, "sda", GPIO_ACTIVE_HIGH),
498c2ecf20Sopenharmony_ci		{ }
508c2ecf20Sopenharmony_ci	},
518c2ecf20Sopenharmony_ci};
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_cistatic struct resource iop3xx_i2c0_resources[] = {
548c2ecf20Sopenharmony_ci	[0] = {
558c2ecf20Sopenharmony_ci		.start	= 0xfffff680,
568c2ecf20Sopenharmony_ci		.end	= 0xfffff697,
578c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_MEM,
588c2ecf20Sopenharmony_ci	},
598c2ecf20Sopenharmony_ci	[1] = {
608c2ecf20Sopenharmony_ci		.start	= IRQ_IOP32X_I2C_0,
618c2ecf20Sopenharmony_ci		.end	= IRQ_IOP32X_I2C_0,
628c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_IRQ,
638c2ecf20Sopenharmony_ci	},
648c2ecf20Sopenharmony_ci};
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_cistruct platform_device iop3xx_i2c0_device = {
678c2ecf20Sopenharmony_ci	.name		= "IOP3xx-I2C",
688c2ecf20Sopenharmony_ci	.id		= 0,
698c2ecf20Sopenharmony_ci	.num_resources	= 2,
708c2ecf20Sopenharmony_ci	.resource	= iop3xx_i2c0_resources,
718c2ecf20Sopenharmony_ci};
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_cistatic struct resource iop3xx_i2c1_resources[] = {
758c2ecf20Sopenharmony_ci	[0] = {
768c2ecf20Sopenharmony_ci		.start	= 0xfffff6a0,
778c2ecf20Sopenharmony_ci		.end	= 0xfffff6b7,
788c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_MEM,
798c2ecf20Sopenharmony_ci	},
808c2ecf20Sopenharmony_ci	[1] = {
818c2ecf20Sopenharmony_ci		.start	= IRQ_IOP32X_I2C_1,
828c2ecf20Sopenharmony_ci		.end	= IRQ_IOP32X_I2C_1,
838c2ecf20Sopenharmony_ci		.flags	= IORESOURCE_IRQ,
848c2ecf20Sopenharmony_ci	}
858c2ecf20Sopenharmony_ci};
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_cistruct platform_device iop3xx_i2c1_device = {
888c2ecf20Sopenharmony_ci	.name		= "IOP3xx-I2C",
898c2ecf20Sopenharmony_ci	.id		= 1,
908c2ecf20Sopenharmony_ci	.num_resources	= 2,
918c2ecf20Sopenharmony_ci	.resource	= iop3xx_i2c1_resources,
928c2ecf20Sopenharmony_ci};
93