From 4575d6f7620755235fe821646fb6c4d341025ca6 Mon Sep 17 00:00:00 2001 From: Tony McKahan Date: Mon, 13 Nov 2017 23:19:45 -0500 Subject: [PATCH] Use Device Tree for RPi screen --- arch/arm/boot/dts/rk3288-miniarm.dts | 11 ++ arch/arm/mach-rockchip/rockchip.c | 15 --- drivers/miniarm/dsi/Kconfig | 10 -- drivers/miniarm/dsi/Makefile | 1 - drivers/miniarm/dsi/asus_mcu.c | 192 --------------------------- drivers/miniarm/dsi/asus_mcu.h | 16 --- 6 files changed, 11 insertions(+), 234 deletions(-) delete mode 100755 drivers/miniarm/dsi/asus_mcu.c delete mode 100644 drivers/miniarm/dsi/asus_mcu.h diff --git a/arch/arm/boot/dts/rk3288-miniarm.dts b/arch/arm/boot/dts/rk3288-miniarm.dts index 9e837353eaea..5b56135c80e0 100755 --- a/arch/arm/boot/dts/rk3288-miniarm.dts +++ b/arch/arm/boot/dts/rk3288-miniarm.dts @@ -603,6 +603,17 @@ &i2c3 { status = "okay"; + + tinker_ft5406: tinker_ft5406@38 { + compatible = "tinker_ft5406"; + reg = <0x38>; + }; + + tinker_mcu: tinker_mcu@45 { + compatible = "tinker_mcu"; + reg = <0x45>; + }; + }; &i2c4 { diff --git a/arch/arm/mach-rockchip/rockchip.c b/arch/arm/mach-rockchip/rockchip.c index cc285b5dc021..5ffdee93755e 100644 --- a/arch/arm/mach-rockchip/rockchip.c +++ b/arch/arm/mach-rockchip/rockchip.c @@ -34,18 +34,6 @@ #define RK3288_GRF_SOC_CON2 0x24C #define RK3288_TIMER6_7_PHYS 0xff810000 -static struct i2c_board_info __initdata i2c_devices_tinker_mcu[] = { - { - I2C_BOARD_INFO("tinker_mcu", 0x45), - }, -}; - -static struct i2c_board_info __initdata i2c_devices_tinker_ft5406[] = { - { - I2C_BOARD_INFO("tinker_ft5406", 0x38), - }, -}; - static void __init rockchip_timer_init(void) { if (of_machine_is_compatible("rockchip,rk3288")) { @@ -75,9 +63,6 @@ static void __init rockchip_dt_init(void) rockchip_suspend_init(); of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); platform_device_register_simple("cpufreq-dt", 0, NULL, 0); - - i2c_register_board_info(3, i2c_devices_tinker_mcu, ARRAY_SIZE(i2c_devices_tinker_mcu)); - i2c_register_board_info(3, i2c_devices_tinker_ft5406, ARRAY_SIZE(i2c_devices_tinker_ft5406)); } static const char * const rockchip_board_dt_compat[] = { diff --git a/drivers/miniarm/dsi/Kconfig b/drivers/miniarm/dsi/Kconfig index 01ad55191856..53a5eb832c1a 100755 --- a/drivers/miniarm/dsi/Kconfig +++ b/drivers/miniarm/dsi/Kconfig @@ -7,16 +7,6 @@ config DRM_PANEL_TOSHIBA_TC358762 Say Y here if you want to enable support for toshiba tc358762 bridge. To compile this driver as a module, choose M here. -config ASUS_RPI_MCU - tristate "RPI MCU for ASUS" - depends on DRM_ROCKCHIP && DRM_PANEL_TOSHIBA_TC358762 - depends on I2C - select RPI_MCU - help - This selects support for TOSHIBA TC358762 bridge specific - extensions for ASUS rpi. If you want to enable MIPI DSI - on RK3288 based SoC, you should selet this option. - config ROCKCHIP_DW_MIPI_DSI2 tristate "Rockchip specific extensions for Synopsys DW MIPI DSI" depends on DRM_ROCKCHIP diff --git a/drivers/miniarm/dsi/Makefile b/drivers/miniarm/dsi/Makefile index 042921ab4a6d..3fb5e4f18a8d 100755 --- a/drivers/miniarm/dsi/Makefile +++ b/drivers/miniarm/dsi/Makefile @@ -1,5 +1,4 @@ obj-$(CONFIG_DRM_PANEL_TOSHIBA_TC358762) += panel-toshiba-tc358762.o -#obj-$(CONFIG_ASUS_RPI_MCU) += asus_mcu.o obj-$(CONFIG_ROCKCHIP_DW_MIPI_DSI2) += dw-mipi-dsi.o #obj-$(CONFIG_TINKER_MCU) += tinker_mcu.o obj-$(CONFIG_TOUCHSCREEN_TINKER_FT5406) += tinker_ft5406.o diff --git a/drivers/miniarm/dsi/asus_mcu.c b/drivers/miniarm/dsi/asus_mcu.c deleted file mode 100755 index 494afc08225e..000000000000 --- a/drivers/miniarm/dsi/asus_mcu.c +++ /dev/null @@ -1,192 +0,0 @@ -/* - * - * RPI Touchscreen MCU driver. - * - * Copyright (c) 2016 ASUSTek Computer Inc. - * Copyright (c) 2012-2014, The Linux Foundation. All rights reserved. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ - -#include -#include -#include -#include -#include -#include -#include "asus_mcu.h" - -struct ts_mcu_data *mdata; - -static int is_hex(char num) -{ - //0-9, a-f, A-F - if ((47 < num && num < 58) || (64 < num && num < 71) || (96 < num && num < 103)) - return 1; - return 0; -} - -static int string_to_byte(const char *source, unsigned char *destination, int size) -{ - int i = 0, counter = 0; - char c[3] = {0}; - unsigned char bytes; - - if (size%2 == 1) - return -EINVAL; - - for(i = 0; i < size; i++){ - if(!is_hex(source[i])) { - return -EINVAL; - } - if(0 == i%2){ - c[0] = source[i]; - c[1] = source[i+1]; - sscanf(c, "%hhx", &bytes); - destination[counter] = bytes; - counter++; - } - } - return 0; -} - -static int send_cmds(struct i2c_client *client, const char *buf) -{ - int ret, size = strlen(buf); - unsigned char byte_cmd[size/2]; - - if ((size%2) != 0) { - LOG_ERR("size should be even\n"); - return -EINVAL; - } - - LOG_INFO("%s\n", buf); - - string_to_byte(buf, byte_cmd, size); - - ret = i2c_master_send(client, byte_cmd, size/2); - if (ret < 0) { - LOG_ERR("send command failed, ret = %d\n", ret); - return ret; - } - - msleep(20); - return 0; -} - -static int recv_cmds(struct i2c_client *client, char *buf, int size) -{ - int ret; - - ret = i2c_master_recv(client, buf, size); - if (ret < 0) { - LOG_ERR("receive commands failed, %d\n", ret); - return ret; - } - msleep(20); - return 0; -} - -static int init_cmd_check(struct ts_mcu_data *mcu_data) -{ - int ret; - char recv_buf[1] = {0}; - - ret = send_cmds(mcu_data->client, "80"); - if (ret < 0) - goto error; - - recv_cmds(mcu_data->client, recv_buf, 1); - if (ret < 0) - goto error; - - LOG_INFO("recv_cmds: 0x%X\n", recv_buf[0]); - if (recv_buf[0] != 0xC3) { - LOG_ERR("read wrong info\n"); - ret = -EINVAL; - goto error; - - } - return 0; - -error: - return ret; -} - -void mcu_power_up(void) -{ - send_cmds(mdata->client, "8500"); - msleep(800); - send_cmds(mdata->client, "8501"); - send_cmds(mdata->client, "86FF"); - send_cmds(mdata->client, "8104"); -} -EXPORT_SYMBOL_GPL(mcu_power_up); - -static int rpi_ts_mcu_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - int ret; - - LOG_INFO("address = 0x%x\n", client->addr); - - if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { - LOG_ERR("I2C check functionality failed\n"); - return -ENODEV; - } - - mdata = kzalloc(sizeof(struct ts_mcu_data), GFP_KERNEL); - if (mdata == NULL) { - LOG_ERR("no memory for device\n"); - return -ENOMEM; - } - - mdata->client = client; - i2c_set_clientdata(client, mdata); - - ret = init_cmd_check(mdata); - if (ret < 0) { - LOG_ERR("init_cmd_check failed, %d\n", ret); - goto error; - } - - return 0; - -error: - kfree(mdata); - return ret; -} - -static int rpi_ts_mcu_remove(struct i2c_client *client) -{ - struct ts_mcu_data *mcu_data = i2c_get_clientdata(client); - - kfree(mcu_data); - return 0; -} - -static const struct i2c_device_id rpi_ts_mcu_id[] = { - {"rpi_ts_mcu", 0}, - {}, -}; - -static struct i2c_driver rpi_ts_mcu_driver = { - .driver = { - .name = "rpi_ts_mcu", - }, - .probe = rpi_ts_mcu_probe, - .remove = rpi_ts_mcu_remove, - .id_table = rpi_ts_mcu_id, -}; -module_i2c_driver(rpi_ts_mcu_driver); - -MODULE_DESCRIPTION("RPI TouchScreen MCU driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/miniarm/dsi/asus_mcu.h b/drivers/miniarm/dsi/asus_mcu.h deleted file mode 100644 index a3f2c51df857..000000000000 --- a/drivers/miniarm/dsi/asus_mcu.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef _RPI_TS_MCU_H_ -#define _RPI_TS_MCU_H_ - -#define LOG_INFO(fmt,arg...) pr_info("%s: "fmt, __func__, ##arg); -#define LOG_ERR(fmt,arg...) pr_err("%s: "fmt, __func__, ##arg); - -#define MAX_I2C_LEN 255 - -struct ts_mcu_data { - struct device *dev; - struct i2c_client *client; - struct delayed_work work; - struct workqueue_struct *wq; -}; - -#endif