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

USB: serial: f81534: fix reading old/new IC config

The F81532/534 had a internal configuration space to save & control
IC state with address F81534_CUSTOM_ADDRESS_START (0x2f00). Layout
as following:
+00h: to indicate the section is valid
+01h~04h: UART Mode & port availability
+05h~08h: Output pin control on IC power on
+09h~12h: Output pin control on working <-- New added

Old driver will use +05~08h as default on working, but newer IC will
configed with shutdown mode(7) in 05h~08h and working mode with RS232(1)
in 09h~12h. It'll make mainstream driver not working.

This patch will make mainstream driver compatible older and newer IC.
If using a old IC, the +05h~08h will be 00h~06h, we'll direct apply it.
If using a new IC, the +05h~08h will be 07h or larger, we'll read +09h~12h
to apply newer configuration.

Signed-off-by: Ji-Ze Hong (Peter Hong) <hpeter+linux_kernel@gmail.com>
Signed-off-by: Johan Hovold <johan@kernel.org>

authored by

Ji-Ze Hong (Peter Hong) and committed by
Johan Hovold
ab60075f 32d8a6fc

+17 -3
+17 -3
drivers/usb/serial/f81534.c
··· 45 45 #define F81534_CONFIG1_REG (0x09 + F81534_UART_BASE_ADDRESS) 46 46 47 47 #define F81534_DEF_CONF_ADDRESS_START 0x3000 48 - #define F81534_DEF_CONF_SIZE 8 48 + #define F81534_DEF_CONF_SIZE 12 49 49 50 50 #define F81534_CUSTOM_ADDRESS_START 0x2f00 51 51 #define F81534_CUSTOM_DATA_SIZE 0x10 52 52 #define F81534_CUSTOM_NO_CUSTOM_DATA 0xff 53 53 #define F81534_CUSTOM_VALID_TOKEN 0xf0 54 54 #define F81534_CONF_OFFSET 1 55 - #define F81534_CONF_GPIO_OFFSET 4 55 + #define F81534_CONF_INIT_GPIO_OFFSET 4 56 + #define F81534_CONF_WORK_GPIO_OFFSET 8 57 + #define F81534_CONF_GPIO_SHUTDOWN 7 58 + #define F81534_CONF_GPIO_RS232 1 56 59 57 60 #define F81534_MAX_DATA_BLOCK 64 58 61 #define F81534_MAX_BUS_RETRY 20 ··· 1340 1337 serial_priv = usb_get_serial_data(serial); 1341 1338 port_priv = usb_get_serial_port_data(port); 1342 1339 1343 - idx = F81534_CONF_GPIO_OFFSET + port_priv->phy_num; 1340 + idx = F81534_CONF_INIT_GPIO_OFFSET + port_priv->phy_num; 1344 1341 value = serial_priv->conf_data[idx]; 1342 + if (value >= F81534_CONF_GPIO_SHUTDOWN) { 1343 + /* 1344 + * Newer IC configure will make transceiver in shutdown mode on 1345 + * initial power on. We need enable it before using UARTs. 1346 + */ 1347 + idx = F81534_CONF_WORK_GPIO_OFFSET + port_priv->phy_num; 1348 + value = serial_priv->conf_data[idx]; 1349 + if (value >= F81534_CONF_GPIO_SHUTDOWN) 1350 + value = F81534_CONF_GPIO_RS232; 1351 + } 1352 + 1345 1353 pins = &f81534_port_out_pins[port_priv->phy_num]; 1346 1354 1347 1355 for (i = 0; i < ARRAY_SIZE(pins->pin); ++i) {