Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sc16is7xx: spi interface is added

spi interface for sc16is7xx is added along with Kconfig flag
to enable spi or i2c, thus in a instance we can have either
spi or i2c or both, in sync to the hw.

Signed-off-by: Rama Kiran Kumar Indrakanti <indrakanti_ram@hotmail.com>
Signed-off-by: Jakub Kicinski <kubakici@wp.pl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Rama Kiran Kumar Indrakanti and committed by
Greg Kroah-Hartman
2c837a8a 34d2e458

+140 -10
+35 -8
drivers/tty/serial/Kconfig
··· 1179 1179 help 1180 1180 Support for console on SCCNXP serial ports. 1181 1181 1182 + config SERIAL_SC16IS7XX_CORE 1183 + tristate 1184 + 1182 1185 config SERIAL_SC16IS7XX 1183 - tristate "SC16IS7xx serial support" 1184 - depends on I2C 1185 - select SERIAL_CORE 1186 - select REGMAP_I2C if I2C 1187 - help 1188 - This selects support for SC16IS7xx serial ports. 1189 - Supported ICs are SC16IS740, SC16IS741, SC16IS750, SC16IS752, 1190 - SC16IS760 and SC16IS762. 1186 + tristate "SC16IS7xx serial support" 1187 + select SERIAL_CORE 1188 + depends on I2C || SPI_MASTER 1189 + help 1190 + This selects support for SC16IS7xx serial ports. 1191 + Supported ICs are SC16IS740, SC16IS741, SC16IS750, SC16IS752, 1192 + SC16IS760 and SC16IS762. Select supported buses using options below. 1193 + 1194 + config SERIAL_SC16IS7XX_I2C 1195 + bool "SC16IS7xx for I2C interface" 1196 + depends on SERIAL_SC16IS7XX 1197 + depends on I2C 1198 + select SERIAL_SC16IS7XX_CORE if SERIAL_SC16IS7XX 1199 + select REGMAP_I2C if I2C 1200 + default y 1201 + help 1202 + Enable SC16IS7xx driver on I2C bus, 1203 + If required say y, and say n to i2c if not required, 1204 + Enabled by default to support oldconfig. 1205 + You must select at least one bus for the driver to be built. 1206 + 1207 + config SERIAL_SC16IS7XX_SPI 1208 + bool "SC16IS7xx for spi interface" 1209 + depends on SERIAL_SC16IS7XX 1210 + depends on SPI_MASTER 1211 + select SERIAL_SC16IS7XX_CORE if SERIAL_SC16IS7XX 1212 + select REGMAP_SPI if SPI_MASTER 1213 + help 1214 + Enable SC16IS7xx driver on SPI bus, 1215 + If required say y, and say n to spi if not required, 1216 + This is additional support to exsisting driver. 1217 + You must select at least one bus for the driver to be built. 1191 1218 1192 1219 config SERIAL_BFIN_SPORT 1193 1220 tristate "Blackfin SPORT emulate UART"
+1 -1
drivers/tty/serial/Makefile
··· 53 53 obj-$(CONFIG_ETRAX_SERIAL) += crisv10.o 54 54 obj-$(CONFIG_SERIAL_ETRAXFS) += etraxfs-uart.o 55 55 obj-$(CONFIG_SERIAL_SCCNXP) += sccnxp.o 56 - obj-$(CONFIG_SERIAL_SC16IS7XX) += sc16is7xx.o 56 + obj-$(CONFIG_SERIAL_SC16IS7XX_CORE) += sc16is7xx.o 57 57 obj-$(CONFIG_SERIAL_JSM) += jsm/ 58 58 obj-$(CONFIG_SERIAL_TXX9) += serial_txx9.o 59 59 obj-$(CONFIG_SERIAL_VR41XX) += vr41xx_siu.o
+104 -1
drivers/tty/serial/sc16is7xx.c
··· 25 25 #include <linux/serial.h> 26 26 #include <linux/tty.h> 27 27 #include <linux/tty_flip.h> 28 + #include <linux/spi/spi.h> 28 29 #include <linux/uaccess.h> 29 30 30 31 #define SC16IS7XX_NAME "sc16is7xx" ··· 1205 1204 .precious_reg = sc16is7xx_regmap_precious, 1206 1205 }; 1207 1206 1207 + #ifdef CONFIG_SERIAL_SC16IS7XX_SPI 1208 + static int sc16is7xx_spi_probe(struct spi_device *spi) 1209 + { 1210 + struct sc16is7xx_devtype *devtype; 1211 + unsigned long flags = 0; 1212 + struct regmap *regmap; 1213 + int ret; 1214 + 1215 + /* Setup SPI bus */ 1216 + spi->bits_per_word = 8; 1217 + /* only supports mode 0 on SC16IS762 */ 1218 + spi->mode = spi->mode ? : SPI_MODE_0; 1219 + spi->max_speed_hz = spi->max_speed_hz ? : 15000000; 1220 + ret = spi_setup(spi); 1221 + if (ret) 1222 + return ret; 1223 + 1224 + if (spi->dev.of_node) { 1225 + const struct of_device_id *of_id = 1226 + of_match_device(sc16is7xx_dt_ids, &spi->dev); 1227 + 1228 + devtype = (struct sc16is7xx_devtype *)of_id->data; 1229 + } else { 1230 + const struct spi_device_id *id_entry = spi_get_device_id(spi); 1231 + 1232 + devtype = (struct sc16is7xx_devtype *)id_entry->driver_data; 1233 + flags = IRQF_TRIGGER_FALLING; 1234 + } 1235 + 1236 + regcfg.max_register = (0xf << SC16IS7XX_REG_SHIFT) | 1237 + (devtype->nr_uart - 1); 1238 + regmap = devm_regmap_init_spi(spi, &regcfg); 1239 + 1240 + return sc16is7xx_probe(&spi->dev, devtype, regmap, spi->irq, flags); 1241 + } 1242 + 1243 + static int sc16is7xx_spi_remove(struct spi_device *spi) 1244 + { 1245 + return sc16is7xx_remove(&spi->dev); 1246 + } 1247 + 1248 + static const struct spi_device_id sc16is7xx_spi_id_table[] = { 1249 + { "sc16is74x", (kernel_ulong_t)&sc16is74x_devtype, }, 1250 + { "sc16is750", (kernel_ulong_t)&sc16is750_devtype, }, 1251 + { "sc16is752", (kernel_ulong_t)&sc16is752_devtype, }, 1252 + { "sc16is760", (kernel_ulong_t)&sc16is760_devtype, }, 1253 + { "sc16is762", (kernel_ulong_t)&sc16is762_devtype, }, 1254 + { } 1255 + }; 1256 + 1257 + MODULE_DEVICE_TABLE(spi, sc16is7xx_spi_id_table); 1258 + 1259 + static struct spi_driver sc16is7xx_spi_uart_driver = { 1260 + .driver = { 1261 + .name = SC16IS7XX_NAME, 1262 + .owner = THIS_MODULE, 1263 + .of_match_table = of_match_ptr(sc16is7xx_dt_ids), 1264 + }, 1265 + .probe = sc16is7xx_spi_probe, 1266 + .remove = sc16is7xx_spi_remove, 1267 + .id_table = sc16is7xx_spi_id_table, 1268 + }; 1269 + 1270 + MODULE_ALIAS("spi:sc16is7xx"); 1271 + #endif 1272 + 1273 + #ifdef CONFIG_SERIAL_SC16IS7XX_I2C 1208 1274 static int sc16is7xx_i2c_probe(struct i2c_client *i2c, 1209 1275 const struct i2c_device_id *id) 1210 1276 { ··· 1321 1253 .remove = sc16is7xx_i2c_remove, 1322 1254 .id_table = sc16is7xx_i2c_id_table, 1323 1255 }; 1324 - module_i2c_driver(sc16is7xx_i2c_uart_driver); 1256 + 1325 1257 MODULE_ALIAS("i2c:sc16is7xx"); 1258 + #endif 1259 + 1260 + static int __init sc16is7xx_init(void) 1261 + { 1262 + int ret = 0; 1263 + #ifdef CONFIG_SERIAL_SC16IS7XX_I2C 1264 + ret = i2c_add_driver(&sc16is7xx_i2c_uart_driver); 1265 + if (ret < 0) { 1266 + pr_err("failed to init sc16is7xx i2c --> %d\n", ret); 1267 + return ret; 1268 + } 1269 + #endif 1270 + 1271 + #ifdef CONFIG_SERIAL_SC16IS7XX_SPI 1272 + ret = spi_register_driver(&sc16is7xx_spi_uart_driver); 1273 + if (ret < 0) { 1274 + pr_err("failed to init sc16is7xx spi --> %d\n", ret); 1275 + return ret; 1276 + } 1277 + #endif 1278 + return ret; 1279 + } 1280 + module_init(sc16is7xx_init); 1281 + 1282 + static void __exit sc16is7xx_exit(void) 1283 + { 1284 + #ifdef CONFIG_SERIAL_SC16IS7XX_I2C 1285 + i2c_del_driver(&sc16is7xx_i2c_uart_driver); 1286 + #endif 1287 + 1288 + #ifdef CONFIG_SERIAL_SC16IS7XX_SPI 1289 + spi_unregister_driver(&sc16is7xx_spi_uart_driver); 1290 + #endif 1291 + } 1292 + module_exit(sc16is7xx_exit); 1326 1293 1327 1294 MODULE_LICENSE("GPL"); 1328 1295 MODULE_AUTHOR("Jon Ringle <jringle@gridpoint.com>");