From 3357370c26e9ef5a9a0071472cb6f549141ec364 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E8=B5=B5=E5=AD=90=E5=88=9D?= Date: Tue, 21 May 2013 18:12:15 +0800 Subject: [PATCH] =?utf8?q?=EF=BB=BFadd=20a85xx=20support?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- drivers/misc/bp/chips/Makefile | 1 + drivers/misc/bp/chips/a85xx.c | 279 +++++++++++++++++++++++++++++++++ include/linux/bp-auto.h | 2 + 3 files changed, 282 insertions(+) create mode 100755 drivers/misc/bp/chips/a85xx.c diff --git a/drivers/misc/bp/chips/Makefile b/drivers/misc/bp/chips/Makefile index 404addb1692b..1015c0bd7be9 100755 --- a/drivers/misc/bp/chips/Makefile +++ b/drivers/misc/bp/chips/Makefile @@ -8,3 +8,4 @@ obj-$(CONFIG_BP_AUTO) += mtk6250.o obj-$(CONFIG_BP_AUTO) += c66a.o obj-$(CONFIG_BP_AUTO) += sew290.o obj-$(CONFIG_BP_AUTO) += u7501.o +obj-$(CONFIG_BP_AUTO) += a85xx.o diff --git a/drivers/misc/bp/chips/a85xx.c b/drivers/misc/bp/chips/a85xx.c new file mode 100755 index 000000000000..ac79d68b7737 --- /dev/null +++ b/drivers/misc/bp/chips/a85xx.c @@ -0,0 +1,279 @@ +/* drivers/misc/bp/chips/a8500.c + * + * Copyright (C) 2012-2015 ROCKCHIP. + * Author: luowei + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + +#if 0 +#define DBG(x...) printk(x) +#else +#define DBG(x...) +#endif + + +/****************operate according to bp chip:start************/ +static int bp_active(struct bp_private_data *bp, int enable) +{ + int result = 0; + + if(enable) + { + printk("<-----a85xx power on-------->\n"); + gpio_set_value(bp->ops->bp_power, GPIO_HIGH); + msleep(100); + gpio_set_value(bp->ops->bp_en,GPIO_HIGH); + mdelay(100); + gpio_set_value(bp->ops->bp_reset, GPIO_LOW); + mdelay(2500); + gpio_set_value(bp->ops->bp_en,GPIO_LOW); + } + else + { + printk("<-----a85xx power off-------->\n"); + gpio_set_value(bp->ops->bp_en, GPIO_LOW); + msleep(2500); + gpio_set_value(bp->ops->bp_en, GPIO_HIGH); + msleep(500); + gpio_set_value(bp->ops->bp_reset, GPIO_HIGH); + gpio_set_value(bp->ops->bp_power, GPIO_LOW); + } + + return result; +} +static void ap_wake_bp_work(struct work_struct *work) +{ + return; +} +static int bp_wake_ap(struct bp_private_data *bp) +{ + int result = 0; + + bp->suspend_status = 0; + wake_lock_timeout(&bp->bp_wakelock, 10 * HZ); + + return result; +} +static int bp_init(struct bp_private_data *bp) +{ + int result = 0; + if(bp->pdata->gpio_valid ==0){ + + } + gpio_direction_output(bp->ops->bp_power, GPIO_LOW); + gpio_direction_output(bp->ops->bp_reset, GPIO_HIGH); + gpio_direction_output(bp->ops->bp_en, GPIO_LOW); + gpio_direction_output(bp->ops->ap_wakeup_bp, GPIO_HIGH); + gpio_direction_input(bp->ops->bp_wakeup_ap); + gpio_pull_updown(bp->ops->bp_wakeup_ap, 1); + INIT_DELAYED_WORK(&bp->wakeup_work, ap_wake_bp_work); + return result; +} + +static int bp_reset(struct bp_private_data *bp) +{ + printk("ioctrl a85xx reset !!! \n"); + gpio_set_value(bp->ops->bp_reset, GPIO_HIGH); + msleep(2000); + gpio_set_value(bp->ops->bp_reset, GPIO_LOW); + return 0; +} +static int bp_shutdown(struct bp_private_data *bp) +{ + int result = 0; + + if(bp->ops->active) + bp->ops->active(bp, 0); + + cancel_delayed_work_sync(&bp->wakeup_work); + + return result; +} +static int bp_suspend(struct bp_private_data *bp) +{ + + bp->suspend_status = 1; + gpio_set_value(bp->ops->ap_wakeup_bp, GPIO_LOW); + + return 0; +} +static int bp_resume(struct bp_private_data *bp) +{ + + bp->suspend_status = 0; + gpio_set_value(bp->ops->ap_wakeup_bp, GPIO_HIGH); + + return 0; +} + + +struct bp_operate bp_a85xx_ops = { +#if defined(CONFIG_ARCH_RK2928) + .name = "a85xx", + .bp_id = BP_ID_A85XX, + .bp_bus = BP_BUS_TYPE_UART, + .bp_pid = 0, + .bp_vid = 0, + .bp_power = RK2928_PIN3_PC2, // 3g_power + .bp_en = RK2928_PIN3_PC5,//BP_UNKNOW_DATA, // 3g_en + .bp_reset = RK2928_PIN0_PB6, + .ap_ready = RK2928_PIN0_PD0, // + .bp_ready = RK2928_PIN0_PD6, + .ap_wakeup_bp = RK2928_PIN3_PC4, + .bp_wakeup_ap = RK2928_PIN3_PC3, // + .bp_assert = BP_UNKNOW_DATA, + .bp_uart_en = BP_UNKNOW_DATA, //EINT9 + .bp_usb_en = BP_UNKNOW_DATA, //W_disable + .trig = IRQF_TRIGGER_RISING,//IRQF_TRIGGER_FALLING,//IRQF_TRIGGER_RISING, + + .active = bp_active, + .init = bp_init, + .reset = bp_reset, + .ap_wake_bp = NULL, + .bp_wake_ap = bp_wake_ap, + .shutdown = bp_shutdown, + .read_status = NULL, + .write_status = NULL, + .suspend = bp_suspend, + .resume = bp_resume, + .misc_name = NULL, + .private_miscdev = NULL, +#elif defined(CONFIG_ARCH_RK30) + .name = "a85xx", + .bp_id = BP_ID_A85XX, + .bp_bus = BP_BUS_TYPE_UART, + .bp_pid = 0, + .bp_vid = 0, + .bp_power = BP_UNKNOW_DATA, // RK2928_PIN3_PC2, // 3g_power + .bp_en = BP_UNKNOW_DATA, // RK2928_PIN3_PC5,//BP_UNKNOW_DATA, // 3g_en + .bp_reset = BP_UNKNOW_DATA, // RK2928_PIN0_PB6, + .ap_ready = BP_UNKNOW_DATA, // RK2928_PIN0_PD0, // + .bp_ready = BP_UNKNOW_DATA, // RK2928_PIN0_PD6, + .ap_wakeup_bp = BP_UNKNOW_DATA, // RK2928_PIN3_PC4, + .bp_wakeup_ap = BP_UNKNOW_DATA, // RK2928_PIN3_PC3, // + .bp_assert = BP_UNKNOW_DATA, + .bp_uart_en = BP_UNKNOW_DATA, //EINT9 + .bp_usb_en = BP_UNKNOW_DATA, //W_disable + .trig = IRQF_TRIGGER_FALLING, + + .active = bp_active, + .init = bp_init, + .reset = bp_reset, + .ap_wake_bp = NULL, + .bp_wake_ap = bp_wake_ap, + .shutdown = bp_shutdown, + .read_status = NULL, + .write_status = NULL, + .suspend = bp_suspend, + .resume = bp_resume, + .misc_name = NULL, + .private_miscdev = NULL, +#else + .name = "a85xx", + .bp_id = BP_ID_A85XX, + .bp_bus = BP_BUS_TYPE_UART, + .bp_pid = 0, + .bp_vid = 0, + .bp_power = BP_UNKNOW_DATA, // RK2928_PIN3_PC2, // 3g_power + .bp_en = BP_UNKNOW_DATA, // RK2928_PIN3_PC5,//BP_UNKNOW_DATA, // 3g_en + .bp_reset = BP_UNKNOW_DATA, // RK2928_PIN0_PB6, + .ap_ready = BP_UNKNOW_DATA, // RK2928_PIN0_PD0, // + .bp_ready = BP_UNKNOW_DATA, // RK2928_PIN0_PD6, + .ap_wakeup_bp = BP_UNKNOW_DATA, // RK2928_PIN3_PC4, + .bp_wakeup_ap = BP_UNKNOW_DATA, // RK2928_PIN3_PC3, // + .bp_assert = BP_UNKNOW_DATA, + .bp_uart_en = BP_UNKNOW_DATA, //EINT9 + .bp_usb_en = BP_UNKNOW_DATA, //W_disable + .trig = IRQF_TRIGGER_FALLING, + + .active = bp_active, + .init = bp_init, + .reset = bp_reset, + .ap_wake_bp = NULL, + .bp_wake_ap = bp_wake_ap, + .shutdown = bp_shutdown, + .read_status = NULL, + .write_status = NULL, + .suspend = bp_suspend, + .resume = bp_resume, + .misc_name = NULL, + .private_miscdev = NULL, +#endif +}; + +/****************operate according to bp chip:end************/ + +//function name should not be changed +static struct bp_operate *bp_get_ops(void) +{ + return &bp_a85xx_ops; +} + +static int __init bp_a85xx_init(void) +{ + struct bp_operate *ops = bp_get_ops(); + int result = 0; + result = bp_register_slave(NULL, NULL, bp_get_ops); + if(result) + { + return result; + } + + if(ops->private_miscdev) + { + result = misc_register(ops->private_miscdev); + if (result < 0) { + printk("%s:misc_register err\n",__func__); + return result; + } + } + + DBG("%s\n",__func__); + return result; +} + +static void __exit bp_a85xx_exit(void) +{ + //struct bp_operate *ops = bp_get_ops(); + bp_unregister_slave(NULL, NULL, bp_get_ops); +} + + +subsys_initcall(bp_a85xx_init); +module_exit(bp_a85xx_exit); + diff --git a/include/linux/bp-auto.h b/include/linux/bp-auto.h index 8ade775d1913..a2609e352a13 100644 --- a/include/linux/bp-auto.h +++ b/include/linux/bp-auto.h @@ -39,6 +39,8 @@ enum bp_id{ BP_ID_U5501, //11 LONGSUNG U5501 WCDMA BP_ID_U7501, //12 LONGSUNG U7501 WCDMA/HSPA+ BP_ID_AW706, //13 ANICARE AW706 EDGE + BP_ID_A85XX, //14 LONGSUNG A8520/A8530 GSM + BP_ID_NUM, }; -- 2.34.1