From d09c3a008834afc3896e877ff40c09d98da05bf8 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman <gregkh@google.com> Date: Thu, 2 May 2024 07:54:35 +0000 Subject: [PATCH] Revert "serial: max310x: implement I2C support" This reverts commit 85d79478710ad2cbf11857aec107084a7104943e which is commit 2e1f2d9a9bdbe12ee475c82a45ac46a278e8049a upstream. It breaks the Android kernel abi and can be brought back in the future in an abi-safe way if it is really needed. Bug: 161946584 Change-Id: I16bdb88a23acb5148cb53af95b47e75c14ce83c3 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> --- drivers/tty/serial/Kconfig | 1 - drivers/tty/serial/max310x.c | 135 +---------------------------------- 2 files changed, 1 insertion(+), 135 deletions(-) diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig index 141195dce98b4..940db397dae2a 100644 --- a/drivers/tty/serial/Kconfig +++ b/drivers/tty/serial/Kconfig @@ -342,7 +342,6 @@ config SERIAL_MAX310X depends on SPI_MASTER select SERIAL_CORE select REGMAP_SPI if SPI_MASTER - select REGMAP_I2C if I2C help This selects support for an advanced UART from Maxim (Dallas). Supported ICs are MAX3107, MAX3108, MAX3109, MAX14830. diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c index ed1aaa19854fd..b90281ac54c85 100644 --- a/drivers/tty/serial/max310x.c +++ b/drivers/tty/serial/max310x.c @@ -14,7 +14,6 @@ #include <linux/delay.h> #include <linux/device.h> #include <linux/gpio/driver.h> -#include <linux/i2c.h> #include <linux/module.h> #include <linux/mod_devicetable.h> #include <linux/property.h> @@ -74,7 +73,6 @@ /* Extended registers */ #define MAX310X_SPI_REVID_EXTREG MAX310X_REG_05 /* Revision ID */ -#define MAX310X_I2C_REVID_EXTREG (0x25) /* Revision ID */ /* IRQ register bits */ #define MAX310X_IRQ_LSR_BIT (1 << 0) /* LSR interrupt */ @@ -262,10 +260,6 @@ struct max310x_if_cfg { }; struct max310x_devtype { - struct { - unsigned short min; - unsigned short max; - } slave_addr; char name[9]; int nr; u8 mode1; @@ -437,10 +431,6 @@ static const struct max310x_devtype max3107_devtype = { .mode1 = MAX310X_MODE1_AUTOSLEEP_BIT | MAX310X_MODE1_IRQSEL_BIT, .detect = max3107_detect, .power = max310x_power, - .slave_addr = { - .min = 0x2c, - .max = 0x2f, - }, }; static const struct max310x_devtype max3108_devtype = { @@ -449,10 +439,6 @@ static const struct max310x_devtype max3108_devtype = { .mode1 = MAX310X_MODE1_AUTOSLEEP_BIT, .detect = max3108_detect, .power = max310x_power, - .slave_addr = { - .min = 0x60, - .max = 0x6f, - }, }; static const struct max310x_devtype max3109_devtype = { @@ -461,10 +447,6 @@ static const struct max310x_devtype max3109_devtype = { .mode1 = MAX310X_MODE1_AUTOSLEEP_BIT, .detect = max3109_detect, .power = max310x_power, - .slave_addr = { - .min = 0x60, - .max = 0x6f, - }, }; static const struct max310x_devtype max14830_devtype = { @@ -473,10 +455,6 @@ static const struct max310x_devtype max14830_devtype = { .mode1 = MAX310X_MODE1_IRQSEL_BIT, .detect = max14830_detect, .power = max14830_power, - .slave_addr = { - .min = 0x60, - .max = 0x6f, - }, }; static bool max310x_reg_writeable(struct device *dev, unsigned int reg) @@ -1579,97 +1557,6 @@ static struct spi_driver max310x_spi_driver = { }; #endif -#ifdef CONFIG_I2C -static int max310x_i2c_extended_reg_enable(struct device *dev, bool enable) -{ - return 0; -} - -static struct regmap_config regcfg_i2c = { - .reg_bits = 8, - .val_bits = 8, - .cache_type = REGCACHE_RBTREE, - .writeable_reg = max310x_reg_writeable, - .volatile_reg = max310x_reg_volatile, - .precious_reg = max310x_reg_precious, - .max_register = MAX310X_I2C_REVID_EXTREG, -}; - -static const struct max310x_if_cfg max310x_i2c_if_cfg = { - .extended_reg_enable = max310x_i2c_extended_reg_enable, - .rev_id_reg = MAX310X_I2C_REVID_EXTREG, -}; - -static unsigned short max310x_i2c_slave_addr(unsigned short addr, - unsigned int nr) -{ - /* - * For MAX14830 and MAX3109, the slave address depends on what the - * A0 and A1 pins are tied to. - * See Table I2C Address Map of the datasheet. - * Based on that table, the following formulas were determined. - * UART1 - UART0 = 0x10 - * UART2 - UART1 = 0x20 + 0x10 - * UART3 - UART2 = 0x10 - */ - - addr -= nr * 0x10; - - if (nr >= 2) - addr -= 0x20; - - return addr; -} - -static int max310x_i2c_probe(struct i2c_client *client) -{ - const struct max310x_devtype *devtype = - device_get_match_data(&client->dev); - struct i2c_client *port_client; - struct regmap *regmaps[4]; - unsigned int i; - u8 port_addr; - - if (client->addr < devtype->slave_addr.min || - client->addr > devtype->slave_addr.max) - return dev_err_probe(&client->dev, -EINVAL, - "Slave addr 0x%x outside of range [0x%x, 0x%x]\n", - client->addr, devtype->slave_addr.min, - devtype->slave_addr.max); - - regmaps[0] = devm_regmap_init_i2c(client, ®cfg_i2c); - - for (i = 1; i < devtype->nr; i++) { - port_addr = max310x_i2c_slave_addr(client->addr, i); - port_client = devm_i2c_new_dummy_device(&client->dev, - client->adapter, - port_addr); - - regmaps[i] = devm_regmap_init_i2c(port_client, ®cfg_i2c); - } - - return max310x_probe(&client->dev, devtype, &max310x_i2c_if_cfg, - regmaps, client->irq); -} - -static int max310x_i2c_remove(struct i2c_client *client) -{ - max310x_remove(&client->dev); - - return 0; -} - -static struct i2c_driver max310x_i2c_driver = { - .driver = { - .name = MAX310X_NAME, - .of_match_table = max310x_dt_ids, - .pm = &max310x_pm_ops, - }, - .probe_new = max310x_i2c_probe, - .remove = max310x_i2c_remove, -}; -#endif - static int __init max310x_uart_init(void) { int ret; @@ -1683,35 +1570,15 @@ static int __init max310x_uart_init(void) #ifdef CONFIG_SPI_MASTER ret = spi_register_driver(&max310x_spi_driver); if (ret) - goto err_spi_register; -#endif - -#ifdef CONFIG_I2C - ret = i2c_add_driver(&max310x_i2c_driver); - if (ret) - goto err_i2c_register; + uart_unregister_driver(&max310x_uart); #endif - return 0; - -#ifdef CONFIG_I2C -err_i2c_register: - spi_unregister_driver(&max310x_spi_driver); -#endif - -err_spi_register: - uart_unregister_driver(&max310x_uart); - return ret; } module_init(max310x_uart_init); static void __exit max310x_uart_exit(void) { -#ifdef CONFIG_I2C - i2c_del_driver(&max310x_i2c_driver); -#endif - #ifdef CONFIG_SPI_MASTER spi_unregister_driver(&max310x_spi_driver); #endif -- GitLab