1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140 |
- /*
- * cypress_touchkey.c - Platform data for cypress touchkey driver
- *
- * Copyright (C) 2011 Samsung Electronics
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- */
- #define SEC_TOUCHKEY_DEBUG
- /* #define SEC_TOUCHKEY_VERBOSE_DEBUG */
- #include <linux/kernel.h>
- #include <asm/unaligned.h>
- //#include <mach/cpufreq.h>
- #include <linux/input/mt.h>
- #include <linux/of_gpio.h>
- #include <linux/regulator/consumer.h>
- #include <linux/module.h>
- #include <linux/input.h>
- #include <linux/init.h>
- #include <linux/slab.h>
- #include <linux/i2c.h>
- #include <linux/interrupt.h>
- #include <linux/irq.h>
- #include <linux/delay.h>
- #include <linux/platform_device.h>
- #include <linux/gpio.h>
- #include <linux/miscdevice.h>
- #include <linux/i2c/touchkey_i2c.h>
- #include <linux/regulator/consumer.h>
- #include <asm/mach-types.h>
- #include <linux/device.h>
- /* #include <mach/msm8974-gpio.h> */
- #include <linux/of_gpio.h>
- #include <linux/firmware.h>
- #include <linux/uaccess.h>
- #include "issp_extern.h"
- #include "coreriver_extern.h"
- #include <linux/mfd/pm8xxx/pm8921.h>
- #ifdef CONFIG_HAS_EARLYSUSPEND
- #include <linux/earlysuspend.h>
- #endif
- /*
- #define CYPRESS_GEN 0X00
- #define CYPRESS_FW_VER 0X01
- #define CYPRESS_MODULE_VER 0X02
- #define CYPRESS_2ND_HOST 0X03
- #define CYPRESS_THRESHOLD 0X04
- #define CYPRESS_AUTO_CAL_FLG 0X05
- #define CYPRESS_IDAC_MENU 0X07
- #define CYPRESS_IDAC_BACK 0X06
- #define CYPRESS_IDAC_HOME 0X08
- #define CYPRESS_DIFF_MENU 0x0C
- #define CYPRESS_DIFF_BACK 0x0A
- #define CYPRESS_DIFF_HOME 0x0E
- #define CYPRESS_RAW_DATA_MENU 0x10
- #define CYPRESS_RAW_DATA_BACK 0x0E
- #define CYPRESS_RAW_DATA_HOME 0x12
- #define CYPRESS_RAW_DATA_BACK_GOGH 0x14
- #define CYPRESS_DATA_UPDATE 0X40
- #define CYPRESS_AUTO_CAL 0X50
- #define CYPRESS_SLEEP 0X80
- #define CYPRESS_FW_ID_REG 0X05
- #define USE_OPEN_CLOSE
- #undef DO_NOT_USE_FUNC_PARAM
- #define KEYCODE_REG 0x00
- */
- /* bit masks*/
- #define PRESS_BIT_MASK 0X08
- #define KEYCODE_BIT_MASK 0X07
- /*
- #define TOUCHKEY_LOG(k, v) dev_notice(&info->client->dev, "key[%d] %d\n", k, v);
- #define FUNC_CALLED dev_notice(&info->client->dev, "%s: called.\n", __func__);
- */
- /*#define NUM_OF_KEY 4*/
- #ifdef USE_OPEN_CLOSE
- static int cypress_input_open(struct input_dev *dev);
- static void cypress_input_close(struct input_dev *dev);
- #endif
- #ifdef CONFIG_HAS_EARLYSUSPEND
- static void cypress_touchkey_early_suspend(struct early_suspend *h);
- static void cypress_touchkey_late_resume(struct early_suspend *h);
- #endif
- #ifdef TK_INFORM_CHARGER
- extern void touchkey_register_callback(void *cb);
- #endif
- static void cypress_config_gpio_i2c(struct cypress_touchkey_platform_data *pdata, int onoff);
- #ifdef TKEY_REQUEST_FW_UPDATE
- static int tkey_load_fw(struct cypress_touchkey_info *info, u8 fw_path);
- static int tkey_unload_fw(struct cypress_touchkey_info *info, u8 fw_path);
- #endif
- static int touchkey_led_status;
- static int touchled_cmd_reversed;
- #ifdef DO_NOT_USE_FUNC_PARAM
- static struct pm_gpio tkey_int = {
- .direction = PM_GPIO_DIR_IN,
- .pull = PM_GPIO_PULL_NO,
- .vin_sel = 2,
- .function = PM_GPIO_FUNC_NORMAL,
- .inv_int_pol = 0,
- };
- static struct pm_gpio tkey_sleep_int = {
- .direction = PM_GPIO_DIR_IN,
- .pull = PM_GPIO_PULL_UP_30,
- .vin_sel = 2,
- .function = PM_GPIO_FUNC_NORMAL,
- .inv_int_pol = 0,
- };
- #endif
- #ifdef TSP_BOOSTER
- static void cypress_change_dvfs_lock(struct work_struct *work)
- {
- struct cypress_touchkey_info *info =
- container_of(work,
- struct cypress_touchkey_info, work_dvfs_chg.work);
- int retval = 0;
- mutex_lock(&info->dvfs_lock);
- retval = set_freq_limit(DVFS_TOUCH_ID, info->dvfs_freq);
- if (retval < 0)
- dev_info(&info->client->dev,
- "%s: booster change failed(%d).\n",
- __func__, retval);
- info->dvfs_lock_status = false;
- mutex_unlock(&info->dvfs_lock);
- }
- static void cypress_set_dvfs_off(struct work_struct *work)
- {
- struct cypress_touchkey_info *info =
- container_of(work,
- struct cypress_touchkey_info, work_dvfs_off.work);
- int retval;
- mutex_lock(&info->dvfs_lock);
- retval = set_freq_limit(DVFS_TOUCH_ID, -1);
- if (retval < 0)
- dev_info(&info->client->dev,
- "%s: booster stop failed(%d).\n",
- __func__, retval);
- info->dvfs_lock_status = true;
- mutex_unlock(&info->dvfs_lock);
- }
- static void cypress_set_dvfs_lock(struct cypress_touchkey_info *info,
- uint32_t on)
- {
- int ret = 0;
- if (info->is_powering_on) {/*0603 - SMD issue*/
- dev_info(&info->client->dev,
- "%s: ignoring dvfs set.\n", __func__);
- return;
- }
- if (info->dvfs_boost_mode == DVFS_STAGE_NONE) {
- dev_dbg(&info->client->dev,
- "%s: DVFS stage is none(%d)\n",
- __func__, info->dvfs_boost_mode);
- return;
- }
- mutex_lock(&info->dvfs_lock);
- if (on == 0) {
- cancel_delayed_work(&info->work_dvfs_chg);
- if (info->dvfs_lock_status) {
- ret = set_freq_limit(DVFS_TOUCH_ID, info->dvfs_freq);
- if (ret < 0)
- dev_info(&info->client->dev,
- "%s: cpu first lock failed(%d)\n", __func__, ret);
- info->dvfs_lock_status = false;
- }
- schedule_delayed_work(&info->work_dvfs_off,
- msecs_to_jiffies(TOUCH_BOOSTER_CHG_TIME));
- } else if (on == 1) {
- cancel_delayed_work(&info->work_dvfs_off);
- schedule_delayed_work(&info->work_dvfs_chg,
- msecs_to_jiffies(TOUCH_BOOSTER_OFF_TIME));
- } else if (on == 2) {
- if (info->dvfs_lock_status) {
- cancel_delayed_work(&info->work_dvfs_off);
- cancel_delayed_work(&info->work_dvfs_chg);
- schedule_work(&info->work_dvfs_off.work);
- }
- }
- mutex_unlock(&info->dvfs_lock);
- }
- static void cypress_init_dvfs(struct cypress_touchkey_info *info)
- {
- mutex_init(&info->dvfs_lock);
- info->dvfs_boost_mode = DVFS_STAGE_DUAL;
- info->dvfs_freq = MIN_TOUCH_LIMIT_SECOND;
- INIT_DELAYED_WORK(&info->work_dvfs_off, cypress_set_dvfs_off);
- INIT_DELAYED_WORK(&info->work_dvfs_chg, cypress_change_dvfs_lock);
- info->dvfs_lock_status = true;
- }
- #endif
- static int cypress_touchkey_i2c_read(struct i2c_client *client,
- u8 reg, u8 *val, unsigned int len)
- {
- struct cypress_touchkey_info *info = dev_get_drvdata(&client->dev);
- int err = 0;
- int retry = 3;
- if (!info->enabled) {
- dev_info(&client->dev, "%s: touchkey is not enabled\n", __func__);
- return 0;
- }
- while (retry--) {
- err = i2c_smbus_read_i2c_block_data(client,
- KEYCODE_REG, len, val);
- if (err >= 0)
- return err;
- dev_info(&client->dev, "%s: i2c transfer error.\n", __func__);
- msleep(20);
- }
- return err;
- }
- static int cypress_touchkey_i2c_write(struct i2c_client *client,
- u8 *val, unsigned int len)
- {
- struct cypress_touchkey_info *info = dev_get_drvdata(&client->dev);
- int err = 0;
- int retry = 3;
- if (!info->enabled) {
- dev_info(&client->dev, "%s: touchkey is not enabled\n", __func__);
- return 0;
- }
- while (retry--) {
- err = i2c_smbus_write_i2c_block_data(client,
- KEYCODE_REG, len, val);
- if (err >= 0)
- return err;
- dev_info(&client->dev, "%s: i2c transfer error.\n", __func__);
- msleep(20);
- }
- return err;
- }
- static int tkey_i2c_check(struct cypress_touchkey_info *info)
- {
- struct i2c_client *client = info->client;
- int ret = 0;
- u8 data[3] = { 0, };
- ret = cypress_touchkey_i2c_read(info->client, KEYCODE_REG, data, 4);
- if (ret < 0) {
- dev_err(&client->dev, "Failed to read Module version\n");
- return ret;
- }
- info->ic_fw_ver = data[1];
- info->module_ver = data[2];
- dev_info(&client->dev, "%s: ic_fw_ver = %x, module_ver = %x \n",
- __func__, info->ic_fw_ver, info->module_ver);
- return ret;
- }
- void cypress_power_onoff(struct cypress_touchkey_info *info, int onoff)
- {
- int /*ret = 0, */rc = 0;
- dev_info(&info->client->dev, "%s: power %s\n",
- __func__, onoff ? "on" : "off");
- if (!info->vcc_en) {
- info->vcc_en = regulator_get(&info->client->dev,
- "8226_l6");
- if (IS_ERR(info->vcc_en)) {
- dev_err(&info->client->dev,
- "Regulator(vcc_en) get failed rc = %ld\n", PTR_ERR(info->vcc_en));
- return;
- }
- }
- /* if (info->pdata->vdd_led < 0) {
- if (!info->vdd_led) {
- info->vdd_led = regulator_get(&info->client->dev,
- "vdd_led");
- if (IS_ERR(info->vdd_led)) {
- dev_err(&info->client->dev,
- "Regulator(vdd_led) get failed rc = %ld\n", PTR_ERR(info->vdd_led));
- return;
- }
- rc = regulator_set_voltage(info->vdd_led,
- 3300000, 3300000);
- if (rc) {
- dev_err(&info->client->dev,
- "regulator(vdd_led) set_vtg failed rc=%d\n", rc);
- return;
- }
- }
- }*/
- if (onoff) {
- if (!regulator_is_enabled(info->vcc_en)) {
- rc = regulator_enable(info->vcc_en);
- if (rc) {
- dev_err(&info->client->dev,
- "Regulator vcc_en enable failed rc=%d\n", rc);
- return;
- }
- }
- /* if (info->pdata->vdd_led < 0) {
- if (!regulator_is_enabled(info->vdd_led)) {
- rc = regulator_enable(info->vdd_led);
- if (rc) {
- dev_err(&info->client->dev,
- "Regulator vdd_led enable failed rc=%d\n", rc);
- return;
- }
- }
- }*/
- } else {
- if (regulator_is_enabled(info->vcc_en)) {
- rc = regulator_disable(info->vcc_en);
- if (rc) {
- dev_err(&info->client->dev,
- "Regulator vcc_en disable failed rc=%d\n", rc);
- return;
- }
- }
- /* if (info->pdata->vdd_led < 0) {
- if (regulator_is_enabled(info->vdd_led)) {
- rc = regulator_disable(info->vdd_led);
- if (rc) {
- dev_err(&info->client->dev,
- "Regulator vdd_led disable failed rc=%d\n", rc);
- return;
- }
- }
- }*/
- }
- /* if (info->pdata->vdd_led > 0) {
- ret = gpio_direction_output(info->pdata->vdd_led, onoff);
- if (ret) {
- dev_err(&info->client->dev,
- "%s: unable to set_direction for vdd_led [%d]\n",
- __func__, info->pdata->vdd_led);
- }
- }*/
- }
- #ifdef LED_LDO_WITH_REGULATOR
- static void change_touch_key_led_voltage(struct cypress_touchkey_info *info, int vol_mv)
- {
- struct regulator *tled_regulator;
- int ret;
- vol_mv_level = vol_mv;
- tled_regulator = regulator_get(NULL, "8921_l10");
- if (IS_ERR(tled_regulator)) {
- dev_info(&info->client->dev,
- "%s: failed to get resource touch_led\n", __func__);
- return;
- }
- ret = regulator_set_voltage(tled_regulator,
- vol_mv * 100000, vol_mv * 100000);
- if (ret)
- dev_info(&info->client->dev,
- "%s: error setting voltage\n", __func__);
- regulator_put(tled_regulator);
- }
- static ssize_t cypress_touchkey_brightness_control(struct device *dev,
- struct device_attribute *attr, const char *buf, size_t size)
- {
- struct cypress_touchkey_info *info = dev_get_drvdata(dev);
- int data;
- if (sscanf(buf, "%d\n", &data) == 1)
- change_touch_key_led_voltage(info, data);
- else
- dev_info(&info->client->dev, "%s: Error[%d]\n",
- __func__, data);
- return size;
- }
- #endif
- #ifdef TK_INFORM_CHARGER
- static int touchkey_ta_setting(struct cypress_touchkey_info *info)
- {
- u8 data[6] = { 0, };
- int count = 0;
- int ret = 0;
- u8 retry = 0;
- while (retry < 3) {
- ret = cypress_touchkey_i2c_read(info->client, KEYCODE_REG, data, 4);
- if (ret < 0) {
- dev_err(&info->client->dev, "Failed to read Keycode_reg.\n");
- return ret;
- }
- /* Send autocal Command */
- if (info->charging_mode) {
- data[0] = 0x90;
- data[3] = 0x10;
- } else {
- data[0] = 0x90;
- data[3] = 0x20;
- }
- count = cypress_touchkey_i2c_write(info->client, data, 4);
- msleep(100);
- /* Check autocal status */
- ret = cypress_touchkey_i2c_read(info->client, KEYCODE_REG, data, 6);
- if (info->charging_mode) {
- if (data[5] & TK_BIT_TA_ON) {
- dev_dbg(&info->client->dev, "%s: TA mode is Enabled\n", __func__);
- break;
- } else {
- dev_err(&info->client->dev, "%s: TA Enabled Error! retry=%d\n",
- __func__, retry);
- }
- } else {
- if (!(data[5] & TK_BIT_TA_ON)) {
- dev_dbg(&info->client->dev, "%s: TA mode is Disabled\n", __func__);
- break;
- } else {
- dev_err(&info->client->dev, "%s: TA Disabled Error! retry=%d\n",
- __func__, retry);
- }
- }
- retry = retry + 1;
- }
- if (retry == 3)
- dev_err(&info->client->dev, "%s: Failed to set the TA mode\n", __func__);
- return count;
- }
- static void cypress_touchkey_ta_cb(struct touchkey_callbacks *cb, bool ta_status)
- {
- struct cypress_touchkey_info *info =
- container_of(cb, struct cypress_touchkey_info, callbacks);
- info->charging_mode = ta_status;
- if (!(info->enabled)) {
- dev_info(&info->client->dev, "%s: Touchkey is not enabled.\n",
- __func__);
- info->done_ta_setting = false;
- return;
- }
- dev_info(&info->client->dev, "%s: TA %s\n",
- __func__, info->charging_mode ? "connected" : "disconnected");
- touchkey_ta_setting(info);
- }
- #endif
- #ifdef CONFIG_GLOVE_TOUCH
- static void cypress_touchkey_glove_work(struct work_struct *work)
- {
- struct cypress_touchkey_info *info =
- container_of(work, struct cypress_touchkey_info, glove_work);
- u8 data[6] = { 0, };
- int count = 0;
- int ret = 0;
- u8 retry = 0;
- while (retry < 3) {
- ret = cypress_touchkey_i2c_read(info->client, CYPRESS_GEN, data, 4);
- if (ret < 0) {
- dev_err(&info->client->dev, "%s: Failed to read Keycode_reg.\n",
- __func__);
- return;
- }
- if (info->glove_value == 1) {
- /* Send glove Command */
- data[0] = 0xA0;
- data[3] = 0x30;
- } else {
- data[0] = 0xA0;
- data[3] = 0x40;
- }
- count = cypress_touchkey_i2c_write(info->client, data, 4);
- msleep(50);
- /* Check autocal status */
- ret = cypress_touchkey_i2c_read(info->client, CYPRESS_GEN, data, 6);
- if (info->glove_value == 1) {
- if (data[5] & TK_BIT_GLOVE) {
- dev_dbg(&info->client->dev, "%s: Glove mode is enabled\n", __func__);
- break;
- } else {
- dev_err(&info->client->dev, "%s: glove_mode Error! retry=%d\n",
- __func__, retry);
- }
- } else {
- if (!(data[5] & TK_BIT_GLOVE)) {
- dev_dbg(&info->client->dev, "%s: Normal mode from Glove mode\n", __func__);
- break;
- } else {
- dev_err(&info->client->dev, "%s: normal_mode Error! retry=%d\n",
- __func__, retry);
- }
- }
- retry = retry + 1;
- }
- if (retry == 3)
- dev_err(&info->client->dev, "%s: Failed to set the glove mode\n", __func__);
- return;
- }
- int cypress_touchkey_glovemode(struct cypress_touchkey_info *info, int value)
- {
- if (!(info->enabled)) {
- dev_info(&info->client->dev, "%s Touchkey is not enabled.\n",
- __func__);
- return 0;
- }
- if (info->glove_value == value) {
- dev_info(&info->client->dev, "glove mode is already %s\n", value ? "enabled" : "disabled");
- return 0;
- }
- info->glove_value = value;
- queue_work(info->glove_wq, &info->glove_work);
- return 0;
- }
- #endif
- #ifdef TKEY_FLIP_MODE
- void cypress_touchkey_flip_cover(struct cypress_touchkey_info *info, int value)
- {
- u8 data[6] = { 0, };
- int ret = 0;
- u8 retry = 0;
- if (!(info->enabled)) {
- dev_info(&info->client->dev, "%s : Touchkey is not enabled.\n",
- __func__);
- return ;
- }
- while (retry < 3) {
- ret = cypress_touchkey_i2c_read(info->client, KEYCODE_REG, data, 4);
- if (ret <= 0) {
- dev_info(&info->client->dev, "%s: Failed to read Keycode_reg.\n",
- __func__);
- return;
- }
- if (value == 1) {
- /* Send filp mode Command */
- data[0] = 0xA0;
- data[3] = 0x50;
- } else {
- data[0] = 0xA0;
- data[3] = 0x40;
- }
- ret = cypress_touchkey_i2c_write(info->client, data, 4);
- if (ret < 0) {
- dev_info(&info->client->dev, "%s: Failed to write flip mode command.\n",
- __func__);
- return;
- }
- msleep(100);
- /* Check autocal status */
- ret = cypress_touchkey_i2c_read(info->client, KEYCODE_REG, data, 6);
- if (ret <= 0) {
- dev_info(&info->client->dev, "%s: Failed to check autocal status.\n",
- __func__);
- return;
- }
- dev_dbg(&info->client->dev,
- "data[5]=%x",data[5] & TK_BIT_FLIP);
- if (value == 1) {
- if (data[5] & TK_BIT_FLIP) {
- dev_dbg(&info->client->dev, "%s: Flip mode is enabled\n", __func__);
- info->enabled_flip = true;
- break;
- } else {
- dev_err(&info->client->dev, "%s: flip_mode Enable failed. retry=%d\n",
- __func__, retry);
- }
- } else {
- if (!(data[5] & TK_BIT_FLIP)) {
- dev_dbg(&info->client->dev, "%s: Normal mode form Flip mode\n", __func__);
- info->enabled_flip = false;
- break;
- } else {
- dev_info(&info->client->dev, "%s: normal_mode Enable failed. retry=%d \n",
- __func__, retry);
- }
- }
- retry = retry + 1;
- }
- if (retry == 3)
- dev_err(&info->client->dev, "[Touchkey] flip cover failed\n");
- return;
- }
- #endif
- static irqreturn_t cypress_touchkey_interrupt(int irq, void *dev_id)
- {
- struct cypress_touchkey_info *info = dev_id;
- u8 buf[10] = {0,};
- int code;
- int press;
- int ret;
- ret = gpio_get_value(info->pdata->gpio_int);
- if (ret) {
- dev_info(&info->client->dev,
- "%s: not real interrupt (%d).\n", __func__, ret);
- goto out;
- }
- if (info->is_powering_on) {
- dev_info(&info->client->dev,
- "%s: ignoring spurious boot interrupt\n", __func__);
- goto out;
- }
- buf[0] = i2c_smbus_read_byte_data(info->client, CYPRESS_GEN);
- if (buf[0] < 0) {
- dev_info(&info->client->dev, "%s: interrupt failed with %d.\n",
- __func__, ret);
- goto out;
- }
- press = !(buf[0] & PRESS_BIT_MASK);
- code = (int)(buf[0] & KEYCODE_BIT_MASK) - 1;
- dev_info(&info->client->dev,
- "%s: code=%d %s. fw_ver=0x%x, module_ver=0x%x \n", __func__,
- code, press ? "pressed" : "released", info->ic_fw_ver, info->module_ver);
- if (code < 0) {
- dev_info(&info->client->dev,
- "%s, not profer interrupt 0x%2X.(release all finger)\n",
- __func__, buf[0]);
- /* need release all finger function. */
- goto out;
- }
- input_report_key(info->input_dev, info->keycode[code], press);
- input_sync(info->input_dev);
- #ifdef TSP_BOOSTER
- cypress_set_dvfs_lock(info, !!press);
- #endif
- out:
- return IRQ_HANDLED;
- }
- static void cypress_touchkey_con_hw(struct cypress_touchkey_info *dev_info,
- bool flag)
- {
- struct cypress_touchkey_info *info = dev_info;
- if (info->pdata->vdd_led > 0)
- gpio_set_value(info->pdata->vdd_led, flag ? 1 : 0);
- #if defined(SEC_TOUCHKEY_DEBUG)
- dev_notice(&info->client->dev,
- "%s : called with flag %d.\n", __func__, flag);
- #endif
- }
- static int cypress_touchkey_auto_cal(struct cypress_touchkey_info *info, bool booting)
- {
- u8 data[6] = { 0, };
- int count = 0;
- int ret = 0;
- u8 retry = 0;
- while (retry < 3) {
- ret = cypress_touchkey_i2c_read(info->client, CYPRESS_GEN, data, 4);
- if (ret < 0) {
- dev_info(&info->client->dev, "%s: autocal read fail.\n", __func__);
- return ret;
- }
- data[0] = 0x50;
- data[3] = 0x01;
- count = cypress_touchkey_i2c_write(info->client, data, 4);
- dev_info(&info->client->dev,
- "%s: data[0]=%x data[1]=%x data[2]=%x data[3]=%x\n",
- __func__, data[0], data[1], data[2], data[3]);
- if (booting)
- msleep(100);
- else
- msleep(130);
- ret = cypress_touchkey_i2c_read(info->client, CYPRESS_GEN, data, 6);
- if (data[5] & TK_BIT_AUTOCAL) {
- dev_dbg(&info->client->dev, "%s: Run Autocal\n", __func__);
- break;
- } else {
- dev_info(&info->client->dev, "%s: autocal failed[%x][%d]\n",
- __func__, data[5], ret);
- }
- retry = retry + 1;
- }
- if (retry == 3)
- dev_err(&info->client->dev, "%s: Failed to Set the Autocalibration\n", __func__);
- return count;
- }
- static int tkey_fw_update(struct cypress_touchkey_info *info, bool force)
- {
- struct i2c_client *client = info->client;
- int retry;
- int ret = 0;
- dev_info(&client->dev, "%s : touchkey_update Start!!\n", __func__);
- if (force == true)
- retry = 2;
- else
- retry = NUM_OF_RETRY_UPDATE;
- cypress_config_gpio_i2c(info->pdata, 0);
- while (retry--) {
- if (ISSP_main(info) == 0) {
- dev_info(&client->dev, "%s : touchkey_update pass!!\n", __func__);
- msleep(50);
- cypress_touchkey_auto_cal(info, false);
- break;
- }
- msleep(50);
- dev_err(&client->dev,
- "%s : touchkey_update failed... retry...\n", __func__);
- }
- cypress_config_gpio_i2c(info->pdata, 1);
- if (retry <= 0) {
- dev_err(&client->dev, "%s : touchkey_update fail\n", __func__);
- return -1;
- }
- msleep(500);
- info->ic_fw_ver = i2c_smbus_read_byte_data(info->client,
- CYPRESS_FW_VER);
- dev_info(&client->dev,
- "%s : FW Ver 0x%02x\n", __func__, info->ic_fw_ver);
- return ret;
- }
- static ssize_t cypress_touchkey_ic_version_read(struct device *dev,
- struct device_attribute *attr, char *buf)
- {
- struct cypress_touchkey_info *info = dev_get_drvdata(dev);
- int count;
- dev_info(&info->client->dev,
- "%s : FW IC Ver 0x%02x\n", __func__, info->ic_fw_ver);
- count = snprintf(buf, 20, "0x%02x\n", info->ic_fw_ver);
- return count;
- }
- static ssize_t cypress_touchkey_src_version_read(struct device *dev,
- struct device_attribute *attr, char *buf)
- {
- struct cypress_touchkey_info *info = dev_get_drvdata(dev);
- int count;
- dev_info(&info->client->dev,
- "%s : FW src ver 0x%02x\n", __func__, info->src_fw_ver);
- count = snprintf(buf, 20, "0x%02x\n", info->src_fw_ver);
- return count;
- }
- static ssize_t cypress_touchkey_firm_status_show(struct device *dev,
- struct device_attribute *attr, char *buf)
- {
- struct cypress_touchkey_info *info = dev_get_drvdata(dev);
- int count = 0;
- char buff[16] = {0};
- dev_info(&info->client->dev, "%s touchkey_update_status: %d\n",
- __func__, info->touchkey_update_status);
- if (info->touchkey_update_status == DOWNLOADING)
- count = snprintf(buff, sizeof(buff), "Downloading\n");
- else if (info->touchkey_update_status == UPDATE_FAIL)
- count = snprintf(buff, sizeof(buff), "FAIL\n");
- else if (info->touchkey_update_status == UPDATE_PASS)
- count = snprintf(buff, sizeof(buff), "PASS\n");
- return count;
- }
- static ssize_t cypress_touchkey_update_write(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t size)
- {
- struct cypress_touchkey_info *info = dev_get_drvdata(dev);
- struct i2c_client *client = info->client;
- int count = 0;
- #ifdef TKEY_REQUEST_FW_UPDATE
- u8 fw_path;
- #endif
- dev_info(&info->client->dev, "%s \n", __func__);
- #ifdef TKEY_REQUEST_FW_UPDATE
- switch (*buf) {
- case 's':
- case 'S':
- fw_path = FW_BUILT_IN;
- #if !defined(CONFIG_MACH_JS01LTEDCM) && !defined(CONFIG_MACH_JS01LTESBM)
- if(info->touchkeyid == CYPRESS_TOUCHKEY && info->support_fw_update == false) {
- dev_err(&client->dev, "%s: module %x does not support fw update\n.", __func__, info->module_ver);
- return size;
- }
- #endif
- break;
- case 'i':
- case 'I':
- fw_path = FW_IN_SDCARD;
- break;
- default:
- dev_err(&client->dev, "%s: invalid parameter %c\n.", __func__,
- *buf);
- return -EINVAL;
- }
- count = tkey_load_fw(info, fw_path);
- if (count < 0) {
- dev_err(&client->dev, "fail to load fw in %d (%d)\n",
- fw_path, count);
- return count;
- }
- #endif
- info->touchkey_update_status = DOWNLOADING;
- disable_irq(info->irq);
- if (info->touchkeyid == CYPRESS_TOUCHKEY)
- count = tkey_fw_update(info, false);
- else
- count = coreriver_fw_update(info, false);
- if (count < 0) {
- if (info->pdata->gpio_led_en)
- cypress_touchkey_con_hw(info, false);
- cypress_power_onoff(info, 0);
- info->touchkey_update_status = UPDATE_FAIL;
- dev_err(&client->dev, "%s: fail to flash fw (%d)\n.", __func__, count);
- return count;
- }
- info->touchkey_update_status = UPDATE_PASS;
- #ifdef TKEY_REQUEST_FW_UPDATE
- tkey_unload_fw(info, fw_path);
- #endif
- enable_irq(info->irq);
- return size;
- }
- static ssize_t cypress_touchkey_led_control(struct device *dev,
- struct device_attribute *attr, const char *buf,
- size_t size)
- {
- struct cypress_touchkey_info *info = dev_get_drvdata(dev);
- int data;
- int ret;
- static const int ledCmd[] = {TK_CMD_LED_OFF, TK_CMD_LED_ON};
- dev_info(&info->client->dev, "called %s\n", __func__);
- ret = sscanf(buf, "%d", &data);
- if (ret != 1) {
- dev_err(&info->client->dev, "%s, %d err\n",
- __func__, __LINE__);
- return size;
- }
- if (data != 0 && data != 1) {
- dev_err(&info->client->dev, "%s wrong cmd %x\n",
- __func__, data);
- return size;
- }
- if (!info->enabled) {
- touchled_cmd_reversed = 1;
- goto out;
- }
- ret = i2c_smbus_write_byte_data(info->client, CYPRESS_GEN, ledCmd[data]);
- if (ret < 0) {
- dev_info(&info->client->dev,
- "%s: i2c write error [%d]\n", __func__, ret);
- touchled_cmd_reversed = 1;
- goto out;
- }
- #if defined(SEC_TOUCHKEY_DEBUG)
- dev_info(&info->client->dev,
- "touch_led_control : %d\n", data);
- #endif
- msleep(30);
- out:
- touchkey_led_status = ledCmd[data];
- return size;
- }
- static ssize_t cypress_touchkey_sensitivity_control(struct device *dev,
- struct device_attribute *attr, const char *buf,
- size_t size)
- {
- struct cypress_touchkey_info *info = dev_get_drvdata(dev);
- int ret;
- ret = i2c_smbus_write_byte_data(info->client,
- CYPRESS_GEN, CYPRESS_DATA_UPDATE);
- if (ret < 0) {
- dev_info(&info->client->dev,
- "[Touchkey] fail to CYPRESS_DATA_UPDATE.\n");
- return ret;
- }
- msleep(20);
- return size;
- }
- static ssize_t cypress_touchkey_menu_show(struct device *dev,
- struct device_attribute *attr, char *buf)
- {
- struct cypress_touchkey_info *info = dev_get_drvdata(dev);
- static u16 menu_sensitivity;
- u8 data[14] = { 0, };
- int ret;
- unsigned char sensitivity_control = 0x40;
- cypress_touchkey_i2c_write(info->client, &sensitivity_control, 1);
- ret = cypress_touchkey_i2c_read(info->client, KEYCODE_REG, data, 14);
- dev_dbg(&info->client->dev, "called %s data[10] =%d,data[11] = %d\n", __func__,
- data[10], data[11]);
- menu_sensitivity = ((0x00FF & data[10]) << 8) | data[11];
- return snprintf(buf, 20, "%d\n", menu_sensitivity);
- }
- static ssize_t cypress_touchkey_back_show(struct device *dev,
- struct device_attribute *attr, char *buf)
- {
- struct cypress_touchkey_info *info = dev_get_drvdata(dev);
- static u16 back_sensitivity;
- u8 data[14] = { 0, };
- int ret;
- unsigned char sensitivity_control = 0x40;
- cypress_touchkey_i2c_write(info->client, &sensitivity_control, 1);
- ret = cypress_touchkey_i2c_read(info->client, KEYCODE_REG, data, 14);
- dev_dbg(&info->client->dev, "called %s data[12] =%d,data[13] = %d\n", __func__,
- data[12], data[13]);
- back_sensitivity = ((0x00FF & data[12]) << 8) | data[13];
- return snprintf(buf, 20, "%d\n", back_sensitivity);
- }
- static ssize_t cypress_touchkey_raw_data0_show(struct device *dev,
- struct device_attribute *attr, char *buf)
- {
- struct cypress_touchkey_info *info = dev_get_drvdata(dev);
- static u16 raw_data0;
- u8 data[2] = {0,};
- int ret;
- bool touchkey;
- touchkey = info->pdata->touchkey_order;
- if (0) {
- ret = i2c_smbus_read_i2c_block_data(info->client,
- CYPRESS_RAW_DATA_MENU, ARRAY_SIZE(data), data);
- } else {
- ret = i2c_smbus_read_i2c_block_data(info->client,
- touchkey ? CYPRESS_RAW_DATA_MENU : CYPRESS_RAW_DATA_BACK,
- ARRAY_SIZE(data), data);
- }
- if (ret != ARRAY_SIZE(data)) {
- dev_info(&info->client->dev,
- "[TouchKey] fail to read MENU raw data.\n");
- return ret;
- }
- raw_data0 = ((0x00FF & data[0])<<8) | data[1];
- dev_dbg(&info->client->dev, "called %s , data : %d %d\n",
- __func__, data[0], data[1]);
- return snprintf(buf, 20, "%d\n", raw_data0);
- }
- static ssize_t cypress_touchkey_raw_data1_show(struct device *dev,
- struct device_attribute *attr, char *buf)
- {
- struct cypress_touchkey_info *info = dev_get_drvdata(dev);
- static u16 raw_data1;
- u8 data[2] = {0,};
- int ret;
- bool touchkey;
- touchkey = info->pdata->touchkey_order;
- if (0) {
- ret = i2c_smbus_read_i2c_block_data(info->client,
- CYPRESS_RAW_DATA_BACK_GOGH, ARRAY_SIZE(data), data);
- } else {
- ret = i2c_smbus_read_i2c_block_data(info->client,
- touchkey ? CYPRESS_RAW_DATA_BACK : CYPRESS_RAW_DATA_MENU,
- ARRAY_SIZE(data), data);
- }
- if (ret != ARRAY_SIZE(data)) {
- dev_info(&info->client->dev,
- "[TouchKey] fail to read HOME raw data.\n");
- return ret;
- }
- raw_data1 = ((0x00FF & data[0])<<8) | data[1];
- dev_info(&info->client->dev, "called %s , data : %d %d\n",
- __func__, data[0], data[1]);
- return snprintf(buf, 20, "%d\n", raw_data1);
- }
- static ssize_t cypress_touchkey_idac0_show(struct device *dev,
- struct device_attribute *attr, char *buf)
- {
- struct cypress_touchkey_info *info = dev_get_drvdata(dev);
- static u8 idac0;
- u8 data = 0;
- bool touchkey;
- touchkey = info->pdata->touchkey_order;
- if (0) {
- data = i2c_smbus_read_byte_data(info->client,
- CYPRESS_IDAC_MENU);
- } else {
- data = i2c_smbus_read_byte_data(info->client,
- touchkey ? CYPRESS_IDAC_MENU : CYPRESS_IDAC_BACK);
- }
- dev_info(&info->client->dev, "called %s , data : %d\n", __func__, data);
- idac0 = data;
- return snprintf(buf, 20, "%d\n", idac0);
- }
- static ssize_t cypress_touchkey_idac1_show(struct device *dev,
- struct device_attribute *attr, char *buf)
- {
- struct cypress_touchkey_info *info = dev_get_drvdata(dev);
- static u8 idac1;
- u8 data = 0;
- bool touchkey;
- touchkey = info->pdata->touchkey_order;
- if (0) {
- data = i2c_smbus_read_byte_data(info->client,
- CYPRESS_IDAC_BACK);
- } else {
- data = i2c_smbus_read_byte_data(info->client,
- touchkey ? CYPRESS_IDAC_BACK : CYPRESS_IDAC_MENU);
- }
- dev_info(&info->client->dev, "called %s , data : %d\n", __func__, data);
- idac1 = data;
- return snprintf(buf, 20, "%d\n", idac1);
- }
- #if defined(TK_HOME_ENABLE)
- static ssize_t cypress_touchkey_home_show(struct device *dev,
- struct device_attribute *attr, char *buf)
- {
- struct cypress_touchkey_info *info = dev_get_drvdata(dev);
- static u8 home_sensitivity;
- u8 data[2] = {0,};
- int ret;
- ret = i2c_smbus_read_i2c_block_data(info->client,
- CYPRESS_DIFF_MENU, ARRAY_SIZE(data), data);
- if (ret != ARRAY_SIZE(data)) {
- dev_info(&info->client->dev,
- "[TouchKey] fail to read home sensitivity.\n");
- return ret;
- }
- home_sensitivity = ((0x00FF & data[0])<<8) | data[1];
- dev_info(&info->client->dev, "called %s , data : %d %d\n",
- __func__, data[0], data[1]);
- return snprintf(buf, 20, "%d\n", home_sensitivity);
- }
- static ssize_t cypress_touchkey_raw_data2_show(struct device *dev,
- struct device_attribute *attr, char *buf)
- {
- struct cypress_touchkey_info *info = dev_get_drvdata(dev);
- static u16 raw_data1;
- u8 data[2] = {0,};
- int ret;
- ret = i2c_smbus_read_i2c_block_data(info->client,
- CYPRESS_RAW_DATA_HOME, ARRAY_SIZE(data), data);
- if (ret != ARRAY_SIZE(data)) {
- dev_info(&info->client->dev,
- "[TouchKey] fail to read HOME raw data.\n");
- return ret;
- }
- raw_data1 = ((0x00FF & data[0])<<8) | data[1];
- dev_info(&info->client->dev, "called %s , data : %d %d\n",
- __func__, data[0], data[1]);
- return snprintf(buf, 20, "%d\n", raw_data1);
- }
- static ssize_t cypress_touchkey_idac2_show(struct device *dev,
- struct device_attribute *attr, char *buf)
- {
- struct cypress_touchkey_info *info = dev_get_drvdata(dev);
- static u8 idac1;
- u8 data = 0;
- data = i2c_smbus_read_byte_data(info->client, CYPRESS_IDAC_HOME);
- dev_dbg(&info->client->dev, "called %s , data : %d\n", __func__, data);
- idac1 = data;
- return snprintf(buf, 20, "%d\n", idac1);
- }
- #endif
- static ssize_t cypress_touchkey_threshold_show(struct device *dev,
- struct device_attribute *attr, char *buf)
- {
- struct cypress_touchkey_info *info = dev_get_drvdata(dev);
- static u8 touchkey_threshold;
- u8 data = 0;
- data = i2c_smbus_read_byte_data(info->client, CYPRESS_THRESHOLD);
- dev_info(&info->client->dev, "called %s , data : %d\n", __func__, data);
- touchkey_threshold = data;
- return snprintf(buf, 20, "%d\n", touchkey_threshold);
- }
- static ssize_t cypress_touchkey_autocal_testmode(struct device *dev,
- struct device_attribute *attr, const char *buf,
- size_t size)
- {
- struct cypress_touchkey_info *info = dev_get_drvdata(dev);
- int count = 0;
- int on_off;
- if (sscanf(buf, "%d\n", &on_off) == 1) {
- dev_info(&info->client->dev, "[TouchKey] Test Mode : %d\n", on_off);
- if (on_off == 1) {
- count = i2c_smbus_write_byte_data(info->client,
- CYPRESS_GEN, CYPRESS_DATA_UPDATE);
- }
- } else {
- if (info->pdata->gpio_led_en) {
- cypress_touchkey_con_hw(info, false);
- msleep(50);
- cypress_touchkey_con_hw(info, true);
- msleep(50);
- }
- cypress_touchkey_auto_cal(info, false);
- }
- return count;
- }
- static ssize_t cypress_touchkey_autocal_enable(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t size)
- {
- struct cypress_touchkey_info *info = dev_get_drvdata(dev);
- int data;
- sscanf(buf, "%d\n", &data);
- dev_dbg(&info->client->dev, "%s %d\n", __func__, data);
- if (data == 1)
- cypress_touchkey_auto_cal(info, false);
- return 0;
- }
- static ssize_t cypress_touchkey_autocal_status(struct device *dev,
- struct device_attribute *attr, char *buf)
- {
- u8 data[6];
- int ret;
- struct cypress_touchkey_info *info = dev_get_drvdata(dev);
- dev_dbg(&info->client->dev, "%s\n", __func__);
- ret = i2c_smbus_read_i2c_block_data(info->client,
- CYPRESS_GEN, 6, data);
- if ((data[5] & 0x80))
- return snprintf(buf, 20, "Enabled\n");
- else
- return snprintf(buf, 20, "Disabled\n");
- }
- #if defined(CONFIG_GLOVE_TOUCH)
- static ssize_t cypress_touchkey_glove_mode_enable(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t size)
- {
- struct cypress_touchkey_info *info = dev_get_drvdata(dev);
- int data;
- sscanf(buf, "%d\n", &data);
- dev_info(&info->client->dev, "%s %d\n", __func__, data);
- cypress_touchkey_glovemode(info, data);
- return size;
- }
- #endif
- #ifdef TKEY_FLIP_MODE
- static ssize_t cypress_touchkey_flip_cover_mode_enable(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t size)
- {
- struct cypress_touchkey_info *info = dev_get_drvdata(dev);
- int data;
- sscanf(buf, "%d\n", &data);
- dev_info(&info->client->dev, "%s %d\n", __func__, data);
- cypress_touchkey_flip_cover(info, data);
- return size;
- }
- #endif
- #ifdef TSP_BOOSTER
- static ssize_t boost_level_store(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t count)
- {
- struct cypress_touchkey_info *info = dev_get_drvdata(dev);
- int val, retval;
- dev_info(&info->client->dev, "%s\n", __func__);
- sscanf(buf, "%d", &val);
- if (val != 1 && val != 2 && val != 0) {
- dev_info(&info->client->dev,
- "%s: wrong cmd %d\n", __func__, val);
- return count;
- }
- info->dvfs_boost_mode = val;
- dev_info(&info->client->dev,
- "%s: dvfs_boost_mode = %d\n",
- __func__, info->dvfs_boost_mode);
- if (info->dvfs_boost_mode == DVFS_STAGE_DUAL) {
- info->dvfs_freq = MIN_TOUCH_LIMIT_SECOND;
- dev_info(&info->client->dev,
- "%s: boost_mode DUAL, dvfs_freq = %d\n",
- __func__, info->dvfs_freq);
- } else if (info->dvfs_boost_mode == DVFS_STAGE_SINGLE) {
- info->dvfs_freq = MIN_TOUCH_LIMIT;
- dev_info(&info->client->dev,
- "%s: boost_mode SINGLE, dvfs_freq = %d\n",
- __func__, info->dvfs_freq);
- } else if (info->dvfs_boost_mode == DVFS_STAGE_NONE) {
- info->dvfs_freq = -1;
- retval = set_freq_limit(DVFS_TOUCH_ID, -1);
- if (retval < 0) {
- dev_err(&info->client->dev,
- "%s: booster stop failed(%d).\n",
- __func__, retval);
- info->dvfs_lock_status = false;
- }
- }
- return count;
- }
- #endif
- static DEVICE_ATTR(touchkey_firm_update_status, S_IRUGO | S_IWUSR | S_IWGRP,
- cypress_touchkey_firm_status_show, NULL);
- static DEVICE_ATTR(touchkey_firm_version_panel, S_IRUGO,
- cypress_touchkey_ic_version_read, NULL);
- static DEVICE_ATTR(touchkey_firm_version_phone, S_IRUGO,
- cypress_touchkey_src_version_read, NULL);
- static DEVICE_ATTR(touchkey_firm_update, S_IRUGO | S_IWUSR | S_IWGRP,
- NULL, cypress_touchkey_update_write);
- static DEVICE_ATTR(brightness, S_IRUGO | S_IWUSR | S_IWGRP,
- NULL, cypress_touchkey_led_control);
- static DEVICE_ATTR(touch_sensitivity, S_IRUGO | S_IWUSR | S_IWGRP,
- NULL, cypress_touchkey_sensitivity_control);
- static DEVICE_ATTR(touchkey_menu, S_IRUGO,
- cypress_touchkey_menu_show, NULL);
- static DEVICE_ATTR(touchkey_raw_data0, S_IRUGO,
- cypress_touchkey_raw_data0_show, NULL);
- static DEVICE_ATTR(touchkey_idac0, S_IRUGO,
- cypress_touchkey_idac0_show, NULL);
- static DEVICE_ATTR(touchkey_back, S_IRUGO,
- cypress_touchkey_back_show, NULL);
- static DEVICE_ATTR(touchkey_raw_data1, S_IRUGO,
- cypress_touchkey_raw_data1_show, NULL);
- static DEVICE_ATTR(touchkey_idac1, S_IRUGO,
- cypress_touchkey_idac1_show, NULL);
- static DEVICE_ATTR(touchkey_threshold, S_IRUGO,
- cypress_touchkey_threshold_show, NULL);
- static DEVICE_ATTR(touchkey_autocal_start, S_IRUGO | S_IWUSR | S_IWGRP,
- NULL, cypress_touchkey_autocal_testmode);
- static DEVICE_ATTR(autocal_enable, S_IRUGO | S_IWUSR | S_IWGRP, NULL,
- cypress_touchkey_autocal_enable);
- static DEVICE_ATTR(autocal_stat, S_IRUGO | S_IWUSR | S_IWGRP,
- cypress_touchkey_autocal_status, NULL);
- #ifdef LED_LDO_WITH_REGULATOR
- static DEVICE_ATTR(touchkey_brightness_level, S_IRUGO | S_IWUSR | S_IWGRP,
- NULL, cypress_touchkey_brightness_control);
- #endif
- #if defined(CONFIG_GLOVE_TOUCH)
- static DEVICE_ATTR(glove_mode, S_IRUGO | S_IWUSR | S_IWGRP, NULL,
- cypress_touchkey_glove_mode_enable);
- #endif
- #ifdef TKEY_FLIP_MODE
- static DEVICE_ATTR(flip_mode, S_IRUGO | S_IWUSR | S_IWGRP, NULL,
- cypress_touchkey_flip_cover_mode_enable);
- #endif
- #ifdef TSP_BOOSTER
- static DEVICE_ATTR(boost_level,
- S_IWUSR | S_IWGRP, NULL, boost_level_store);
- #endif
- static struct attribute *touchkey_attributes[] = {
- &dev_attr_touchkey_firm_update_status.attr,
- &dev_attr_touchkey_firm_version_panel.attr,
- &dev_attr_touchkey_firm_version_phone.attr,
- &dev_attr_touchkey_firm_update.attr,
- &dev_attr_brightness.attr,
- &dev_attr_touch_sensitivity.attr,
- &dev_attr_touchkey_menu.attr,
- &dev_attr_touchkey_raw_data0.attr,
- &dev_attr_touchkey_idac0.attr,
- &dev_attr_touchkey_back.attr,
- &dev_attr_touchkey_raw_data1.attr,
- &dev_attr_touchkey_idac1.attr,
- &dev_attr_touchkey_threshold.attr,
- &dev_attr_touchkey_autocal_start.attr,
- &dev_attr_autocal_enable.attr,
- &dev_attr_autocal_stat.attr,
- #ifdef LED_LDO_WITH_REGULATOR
- &dev_attr_touchkey_brightness_level.attr,
- #endif
- #ifdef CONFIG_GLOVE_TOUCH
- &dev_attr_glove_mode.attr,
- #endif
- #ifdef TKEY_FLIP_MODE
- &dev_attr_flip_mode.attr,
- #endif
- #ifdef TSP_BOOSTER
- &dev_attr_boost_level.attr,
- #endif
- NULL,
- };
- static struct attribute_group touchkey_attr_group = {
- .attrs = touchkey_attributes,
- };
- #ifdef TKEY_REQUEST_FW_UPDATE
- static int load_fw_built_in(struct cypress_touchkey_info *info)
- {
- struct i2c_client *client = info->client;
- int ret;
- char *fw_name;
- if (info->touchkeyid == CYPRESS_TOUCHKEY)
- fw_name = kasprintf(GFP_KERNEL, "%s/%s.fw",
- TKEY_FW_BUILTIN_PATH, TKEY_CYPRESS_FW_NAME);
- else
- fw_name = kasprintf(GFP_KERNEL, "%s/%s.fw",
- TKEY_FW_BUILTIN_PATH, TKEY_CORERIVER_FW_NAME);
- pr_info("%s!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n",fw_name);
- ret = request_firmware(&info->fw, fw_name, &client->dev);
- if (ret) {
- dev_err(&client->dev, "error requesting built-in firmware (%d)"
- "\n", ret);
- goto out;
- }
- info->fw_img = (struct fw_image *)info->fw->data;
- info->src_fw_ver = info->fw_img->first_fw_ver;
- dev_info(&client->dev, "the fw 0x%x is loaded (size=%d)\n",
- info->fw_img->first_fw_ver, info->fw_img->fw_len);
- out:
- kfree(fw_name);
- return ret;
- }
- static int load_fw_in_sdcard(struct cypress_touchkey_info *info)
- {
- struct i2c_client *client = info->client;
- int ret;
- mm_segment_t old_fs;
- struct file *fp;
- long nread;
- int len;
- char *fw_name;
- if (info->touchkeyid == CYPRESS_TOUCHKEY)
- fw_name = kasprintf(GFP_KERNEL, "%s/%s.bin",
- TKEY_FW_IN_SDCARD_PATH, TKEY_CYPRESS_FW_NAME);
- else
- fw_name = kasprintf(GFP_KERNEL, "%s/%s.bin",
- TKEY_FW_IN_SDCARD_PATH, TKEY_CORERIVER_FW_NAME);
- old_fs = get_fs();
- set_fs(KERNEL_DS);
- fp = filp_open(fw_name, O_RDONLY, S_IRUSR);
- if (!fp) {
- dev_err(&client->dev, "%s: fail to open fw in %s\n",
- __func__, fw_name);
- ret = -ENOENT;
- goto err_open_fw;
- }
- len = fp->f_path.dentry->d_inode->i_size;
- info->fw_img = kzalloc(len, GFP_KERNEL);
- if (!info->fw_img) {
- dev_err(&client->dev, "%s: fail to alloc mem for fw\n",
- __func__);
- ret = -ENOMEM;
- goto err_alloc;
- }
- nread = vfs_read(fp, (char __user *)info->fw_img, len, &fp->f_pos);
- dev_info(&client->dev, "%s: load fw in internal sd (%ld)\n",
- __func__, nread);
- ret = 0;
- err_alloc:
- filp_close(fp, NULL);
- err_open_fw:
- set_fs(old_fs);
- kfree(fw_name);
- return ret;
- }
- static int tkey_load_fw(struct cypress_touchkey_info *info, u8 fw_path)
- {
- struct i2c_client *client = info->client;
- int ret;
- switch (fw_path) {
- case FW_BUILT_IN:
- ret = load_fw_built_in(info);
- break;
- case FW_IN_SDCARD:
- ret = load_fw_in_sdcard(info);
- break;
- default:
- dev_err(&client->dev, "%s: invalid fw path (%d)\n",
- __func__, fw_path);
- return -ENOENT;
- }
- if (ret < 0) {
- dev_err(&client->dev, "fail to load fw in %d (%d)\n",
- fw_path, ret);
- return ret;
- }
- return 0;
- }
- static int tkey_unload_fw(struct cypress_touchkey_info *info, u8 fw_path)
- {
- struct i2c_client *client = info->client;
- switch (fw_path) {
- case FW_BUILT_IN:
- release_firmware(info->fw);
- break;
- case FW_IN_SDCARD:
- kfree(info->fw_img);
- break;
- default:
- dev_err(&client->dev, "%s: invalid fw path (%d)\n",
- __func__, fw_path);
- return -ENOENT;
- }
- return 0;
- }
- static int tkey_flash_fw(struct cypress_touchkey_info *info, u8 fw_path, bool force)
- {
- struct i2c_client *client = info->client;
- int ret;
- return 0;
- //TEST
- /* firmware load */
- ret = tkey_load_fw(info, fw_path);
- if (ret < 0) {
- dev_err(&client->dev, "%s : fail to load fw (%d)\n", __func__, ret);
- return ret;
- }
- info->cur_fw_path = fw_path;
- if (force == true || info->touchkeyid == CORERIVER_TOUCHKEY ||
- (info->touchkeyid == CYPRESS_TOUCHKEY && (info->module_ver ==0x8 ||info->module_ver == 0x9)))
- info->support_fw_update = true;
- else
- info->support_fw_update = false;
- /* firmware version compare */
- #if defined(CONFIG_MACH_JS01LTEDCM) || defined(CONFIG_MACH_JS01LTESBM)
- if (info->ic_fw_ver >= info->src_fw_ver && !force) {
- #else
- if ((info->ic_fw_ver >= info->src_fw_ver && !force) || info->support_fw_update == false) {
- #endif
- dev_info(&client->dev, "%s : IC aleady have latest firmware (fw:%#x module:%#x)\n",
- __func__ , info->ic_fw_ver, info->module_ver);
- goto out;
- }
- /* firmware update */
- disable_irq(client->irq);
- if (info->touchkeyid == CYPRESS_TOUCHKEY)
- ret = tkey_fw_update(info, force);
- else
- ret = coreriver_fw_update(info, force);
- if (ret < 0) {
- goto err_fw_update;
- }
- enable_irq(client->irq);
- err_fw_update:
- out:
- tkey_unload_fw(info, fw_path);
- return ret;
- }
- #endif
- static void cypress_config_gpio_i2c(struct cypress_touchkey_platform_data *pdata, int onoff)
- {
- if (onoff) {
- gpio_tlmm_config(GPIO_CFG(pdata->gpio_scl, 3, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), 1);
- gpio_tlmm_config(GPIO_CFG(pdata->gpio_sda, 3, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), 1);
- } else {
- gpio_tlmm_config(GPIO_CFG(pdata->gpio_scl, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), 1);
- gpio_tlmm_config(GPIO_CFG(pdata->gpio_sda, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), 1);
- }
- }
- static void cypress_request_gpio(struct cypress_touchkey_platform_data *pdata)
- {
- int ret;
- ret = gpio_request(pdata->gpio_int, "touchkey_irq");
- if (ret) {
- printk(KERN_ERR "%s: unable to request touchkey_irq [%d]\n",
- __func__, pdata->gpio_int);
- }
- if (pdata->gpio_touchkey_id > 0) {
- ret = gpio_request(pdata->gpio_touchkey_id, "touchkey_id");
- if (ret) {
- printk(KERN_ERR "%s: unable to request touchkey_id[%d]\n",
- __func__, pdata->gpio_touchkey_id);
- }
- }
- if (pdata->vdd_led > 0) {
- ret = gpio_request(pdata->vdd_led, "touchkey_vdd_led");
- if (ret) {
- printk(KERN_ERR "%s: unable to request touchkey_vdd_led [%d]\n",
- __func__, pdata->vdd_led);
- }
- }
- }
- #ifdef CONFIG_OF
- static int cypress_get_keycodes(struct device *dev, char *name,
- struct cypress_touchkey_platform_data *pdata)
- {
- struct property *prop;
- struct device_node *np = dev->of_node;
- int rc;
- prop = of_find_property(np, name, NULL);
- if (!prop)
- return -EINVAL;
- if (!prop->value)
- return -ENODATA;
- pdata->keycodes_size = prop->length / sizeof(u32);
- rc = of_property_read_u32_array(np, name, pdata->touchkey_keycode,
- pdata->keycodes_size);
- if (rc && (rc != -EINVAL)) {
- dev_info(dev, "%s: Unable to read %s\n", __func__, name);
- return rc;
- }
- return 0;
- }
- static int cypress_parse_dt(struct device *dev,
- struct cypress_touchkey_platform_data *pdata)
- {
- int rc;
- struct device_node *np = dev->of_node;
- rc = cypress_get_keycodes(dev, "cypress,tkey-keycodes", pdata);
- if (rc)
- return rc;
- /* regulator info */
- pdata->i2c_pull_up = of_property_read_bool(np, "cypress,i2c-pull-up");
- pdata->vdd_led = of_get_named_gpio(np, "vdd_led-gpio", 0);
- /* reset, irq gpio info */
- pdata->gpio_scl = of_get_named_gpio_flags(np, "cypress,scl-gpio",
- 0, &pdata->scl_gpio_flags);
- pdata->gpio_sda = of_get_named_gpio_flags(np, "cypress,sda-gpio",
- 0, &pdata->sda_gpio_flags);
- pdata->gpio_int = of_get_named_gpio_flags(np, "cypress,irq-gpio",
- 0, &pdata->irq_gpio_flags);
- pdata->gpio_touchkey_id = of_get_named_gpio_flags(np, "cypress,touchkey_id-gpio",
- 0, &pdata->gpio_touchkey_id_flags);
- return 0;
- }
- #else
- static int cypress_parse_dt(struct device *dev,
- struct cypress_touchkey_platform_data *pdata)
- {
- return -ENODEV;
- }
- #endif
- static void tkey_check_ic(struct cypress_touchkey_info *info)
- {
- int ret;
- if (info->pdata->gpio_touchkey_id < 0) {
- info->touchkeyid = CYPRESS_TOUCHKEY;
- } else {
- ret = gpio_get_value(info->pdata->gpio_touchkey_id);
- if (ret == 0)
- info->touchkeyid = CORERIVER_TOUCHKEY;
- else
- info->touchkeyid =CYPRESS_TOUCHKEY;
- }
- //TEST
- info->touchkeyid =CYPRESS_TOUCHKEY;
- //TEST
- dev_info(&info->client->dev, "touchkey id = %s\n",
- info->touchkeyid ? "CYPRESS" : "CORERIVER");
- }
- static int cypress_touchkey_probe(struct i2c_client *client,
- const struct i2c_device_id *id)
- {
- struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
- struct cypress_touchkey_platform_data *pdata;
- struct cypress_touchkey_info *info;
- struct input_dev *input_dev;
- struct device *sec_touchkey;
- int ret = 0;
- int i;
- int error;
- bool bforced = false;
- if (!i2c_check_functionality(adapter, I2C_FUNC_I2C))
- return -EIO;
- if (client->dev.of_node) {
- pdata = devm_kzalloc(&client->dev,
- sizeof(struct cypress_touchkey_platform_data),
- GFP_KERNEL);
- if (!pdata) {
- dev_info(&client->dev, "Failed to allocate memory\n");
- return -ENOMEM;
- }
- error = cypress_parse_dt(&client->dev, pdata);
- if (error)
- return error;
- } else
- pdata = client->dev.platform_data;
- cypress_request_gpio(pdata);
- info = kzalloc(sizeof(*info), GFP_KERNEL);
- if (!info) {
- dev_info(&client->dev, "%s: fail to memory allocation.\n", __func__);
- goto err_mem_alloc;
- }
- input_dev = input_allocate_device();
- if (!input_dev) {
- printk(KERN_ERR "%s: fail to allocate input device.\n", __func__);
- goto err_input_dev_alloc;
- }
- client->irq = gpio_to_irq(pdata->gpio_int);
- info->client = client;
- info->input_dev = input_dev;
- info->pdata = pdata;
- info->irq = client->irq;
- info->touchkey_update_status = UPDATE_NONE;
- input_dev->name = "sec_touchkey";
- input_dev->phys = info->phys;
- input_dev->id.bustype = BUS_I2C;
- input_dev->dev.parent = &client->dev;
- set_bit(EV_SYN, input_dev->evbit);
- set_bit(EV_KEY, input_dev->evbit);
- set_bit(EV_LED, input_dev->evbit);
- set_bit(LED_MISC, input_dev->ledbit);
- for (i = 0; i < pdata->keycodes_size; i++) {
- info->keycode[i] = pdata->touchkey_keycode[i];
- set_bit(info->keycode[i], input_dev->keybit);
- }
- i2c_set_clientdata(client, info);
- info->is_powering_on = true;
- if (info->pdata->gpio_led_en)
- cypress_touchkey_con_hw(info, true);
- cypress_power_onoff(info, 1);
- msleep(40);
-
- tkey_check_ic(info);
- if (info->touchkeyid == CORERIVER_TOUCHKEY)
- msleep(160);
- info->enabled = true;
- ret = tkey_i2c_check(info);
- if (ret < 0) {
- dev_err(&client->dev, "i2c_check failed\n");
- #if defined(CONFIG_SEC_FACTORY)
- info->enabled = false;
- goto err_i2c_check;
- #else
- bforced = true;
- #endif
- }
- input_set_drvdata(input_dev, info);
- ret = input_register_device(input_dev);
- if (ret) {
- dev_info(&client->dev, "failed to register input dev (%d).\n",
- ret);
- goto err_reg_input_dev;
- }
- #ifdef USE_OPEN_CLOSE
- input_dev->open = cypress_input_open;
- input_dev->close = cypress_input_close;
- #endif
- dev_info(&info->client->dev, "gpio_to_irq IRQ %d\n",
- client->irq);
- #ifdef TSP_BOOSTER
- cypress_init_dvfs(info);
- #endif
- ret = request_threaded_irq(client->irq, NULL,
- cypress_touchkey_interrupt,
- IRQF_DISABLED | IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
- client->dev.driver->name, info);
- if (ret < 0) {
- dev_info(&client->dev, "Failed to request IRQ %d (err: %d).\n",
- client->irq, ret);
- goto err_req_irq;
- }
- #ifdef CONFIG_HAS_EARLYSUSPEND
- info->early_suspend.level =
- EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
- info->early_suspend.suspend = cypress_touchkey_early_suspend;
- info->early_suspend.resume = cypress_touchkey_late_resume;
- register_early_suspend(&info->early_suspend);
- #endif /* CONFIG_HAS_EARLYSUSPEND */
- #if defined(CONFIG_GLOVE_TOUCH)
- info->glove_wq = create_singlethread_workqueue("cypress_touchkey");
- if (!info->glove_wq)
- dev_info(&client->dev, "fail to create glove workquewe.\n");
- else
- INIT_WORK(&info->glove_work, cypress_touchkey_glove_work);
- #endif
- #ifdef TKEY_REQUEST_FW_UPDATE
- ret = tkey_flash_fw(info, FW_BUILT_IN, bforced);
- if (ret < 0) {
- dev_info(&info->client->dev,
- "%s: tkey fw update failed.\n", __func__);
- goto err_fw_update;
- }
- #else
- info->src_fw_ver = BIN_FW_VERSION;
- #endif
- if (info->touchkeyid == CYPRESS_TOUCHKEY)
- cypress_touchkey_auto_cal(info, true);
- sec_touchkey = device_create(sec_class, NULL, 0, NULL, "sec_touchkey");
- if (IS_ERR(sec_touchkey)) {
- dev_info(&info->client->dev,
- "%s: Failed to create device(sec_touchkey)!\n", __func__);
- goto err_sysfs;
- }
- dev_set_drvdata(sec_touchkey, info);
- ret = sysfs_create_group(&sec_touchkey->kobj,
- &touchkey_attr_group);
- if (ret < 0) {
- dev_err(&info->client->dev,
- "%s: Failed to create sysfs attributes\n",
- __func__);
- goto err_sysfs_group;
- }
- #if defined(TK_INFORM_CHARGER)
- info->pdata->register_cb = touchkey_register_callback;
- info->callbacks.inform_charger = cypress_touchkey_ta_cb;
- if (info->pdata->register_cb) {
- dev_info(&client->dev, "[Touchkey] Register TA Callback\n");
- info->pdata->register_cb(&info->callbacks);
- }
- #endif
- info->is_powering_on = false;
- /*
- cypress_power_onoff(info, 0);
- */
- dev_info(&info->client->dev, "%s: done\n", __func__);
- return 0;
- err_sysfs_group:
- device_destroy(sec_class, 0);
- err_sysfs:
- #ifdef TKEY_REQUEST_FW_UPDATE
- err_fw_update:
- #endif
- if (info->irq >= 0)
- free_irq(info->irq, info);
- #if defined(CONFIG_GLOVE_TOUCH)
- destroy_workqueue(info->glove_wq);
- #endif
- err_req_irq:
- /*
- err_gpio_request:
- */
- input_unregister_device(input_dev);
- err_reg_input_dev:
- input_free_device(input_dev);
- input_dev = NULL;
- #if defined(CONFIG_SEC_FACTORY)
- err_i2c_check:
- #endif
- if (info->pdata->gpio_led_en)
- cypress_touchkey_con_hw(info, false);
- cypress_power_onoff(info, 0);
- err_input_dev_alloc:
- kfree(info);
- return -ENXIO;
- err_mem_alloc:
- return -ENOMEM;
- }
- static int cypress_touchkey_remove(struct i2c_client *client)
- {
- struct cypress_touchkey_info *info = i2c_get_clientdata(client);
- if (info->irq >= 0)
- free_irq(info->irq, info);
- if (info->pdata->vdd_led > 0)
- gpio_free(info->pdata->vdd_led);
- input_unregister_device(info->input_dev);
- input_free_device(info->input_dev);
- kfree(info);
- return 0;
- }
- #if defined(CONFIG_PM) || defined(CONFIG_HAS_EARLYSUSPEND)
- static int cypress_touchkey_suspend(struct device *dev)
- {
- struct i2c_client *client = to_i2c_client(dev);
- struct cypress_touchkey_info *info = i2c_get_clientdata(client);
- int ret = 0;
- #ifdef TSP_BOOSTER
- cypress_set_dvfs_lock(info, 2);
- dev_info(&info->client->dev,
- "%s: dvfs_lock free.\n", __func__);
- #endif
- info->is_powering_on = true;
- disable_irq(info->irq);
- if (info->pdata->gpio_led_en)
- cypress_touchkey_con_hw(info, false);
- cypress_power_onoff(info, 0);
- info->enabled = false;
- return ret;
- }
- static int cypress_touchkey_resume(struct device *dev)
- {
- struct i2c_client *client = to_i2c_client(dev);
- struct cypress_touchkey_info *info = i2c_get_clientdata(client);
- int ret = 0;
- cypress_power_onoff(info, 1);
- if (info->pdata->gpio_led_en)
- cypress_touchkey_con_hw(info, true);
- msleep(50);
- if (info->touchkeyid == CYPRESS_TOUCHKEY) {
- info->enabled = true;
- cypress_touchkey_auto_cal(info, false);
- } else {
- msleep(150);
- info->enabled = true;
- }
- if (touchled_cmd_reversed) {
- touchled_cmd_reversed = 0;
- i2c_smbus_write_byte_data(info->client,
- CYPRESS_GEN, touchkey_led_status);
- dev_info(&client->dev,
- "%s: LED returned on\n", __func__);
- msleep(30);
- }
- enable_irq(info->irq);
- info->is_powering_on = false;
- return ret;
- }
- #endif
- #ifdef CONFIG_HAS_EARLYSUSPEND
- static void cypress_touchkey_early_suspend(struct early_suspend *h)
- {
- struct cypress_touchkey_info *info;
- info = container_of(h, struct cypress_touchkey_info, early_suspend);
- cypress_touchkey_suspend(&info->client->dev);
- }
- static void cypress_touchkey_late_resume(struct early_suspend *h)
- {
- struct cypress_touchkey_info *info;
- info = container_of(h, struct cypress_touchkey_info, early_suspend);
- cypress_touchkey_resume(&info->client->dev);
- }
- #endif
- static const struct i2c_device_id cypress_touchkey_id[] = {
- {"cypress_touchkey", 0},
- {}
- };
- MODULE_DEVICE_TABLE(i2c, cypress_touchkey_id);
- #ifdef CONFIG_OF
- static struct of_device_id cypress_match_table[] = {
- { .compatible = "cypress,cypress-tkey",},
- { },
- };
- #else
- #define cypress_match_table NULL
- #endif
- #ifdef USE_OPEN_CLOSE
- static int cypress_input_open(struct input_dev *dev)
- {
- struct cypress_touchkey_info *info = input_get_drvdata(dev);
- dev_info(&info->client->dev, "%s.\n", __func__);
- cypress_touchkey_resume(&info->client->dev);
- return 0;
- }
- static void cypress_input_close(struct input_dev *dev)
- {
- struct cypress_touchkey_info *info = input_get_drvdata(dev);
- dev_info(&info->client->dev, "%s.\n", __func__);
- cypress_touchkey_suspend(&info->client->dev);
- }
- #endif
- #if defined(CONFIG_PM) && !defined(CONFIG_HAS_EARLYSUSPEND) && !defined(USE_OPEN_CLOSE)
- static const struct dev_pm_ops cypress_touchkey_pm_ops = {
- .suspend = cypress_touchkey_suspend,
- .resume = cypress_touchkey_resume,
- };
- #endif
- struct i2c_driver cypress_touchkey_driver = {
- .probe = cypress_touchkey_probe,
- .remove = cypress_touchkey_remove,
- .driver = {
- .name = "cypress_touchkey",
- .owner = THIS_MODULE,
- .of_match_table = cypress_match_table,
- #if defined(CONFIG_PM) && !defined(CONFIG_HAS_EARLYSUSPEND) && !defined(USE_OPEN_CLOSE)
- .pm = &cypress_touchkey_pm_ops,
- #endif
- },
- .id_table = cypress_touchkey_id,
- };
- /*
- module_i2c_driver(cypress_touchkey_driver);
- */
- static int __init cypress_touchkey_init(void)
- {
- int ret = 0;
- /*
- #ifdef CONFIG_SAMSUNG_LPM_MODE
- if (poweroff_charging) {
- pr_notice("%s : LPM Charging Mode!!\n", __func__);
- return 0;
- }
- #endif
- */
- printk(KERN_ERR "%s\n", __func__);
- ret = i2c_add_driver(&cypress_touchkey_driver);
- if (ret) {
- printk(KERN_ERR "cypress touch keypad registration failed. ret= %d\n",
- ret);
- }
- printk(KERN_ERR "%s: init done %d\n", __func__, ret);
- return ret;
- }
- static void __exit cypress_touchkey_exit(void)
- {
- i2c_del_driver(&cypress_touchkey_driver);
- }
- module_init(cypress_touchkey_init);
- module_exit(cypress_touchkey_exit);
- MODULE_DESCRIPTION("Touchkey driver for Cypress touchkey controller ");
- MODULE_LICENSE("GPL");
|