Commit 94897619 authored by Dudley Du's avatar Dudley Du Committed by Dmitry Torokhov

Input: cyapa - rename 'gen5' to 'pip' for chared code

Change 'gen5' to 'pip' for all macros, variables and functions that are
shared between gen5 and gen6 modules to make naming more clear and
readable.

Also fix a few spelling errors.
Signed-off-by: default avatarDudley Du <dudl@cypress.com>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent be972177
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Daniel Kurtz <djkurtz@chromium.org> * Daniel Kurtz <djkurtz@chromium.org>
* Benson Leung <bleung@chromium.org> * Benson Leung <bleung@chromium.org>
* *
* Copyright (C) 2011-2014 Cypress Semiconductor, Inc. * Copyright (C) 2011-2015 Cypress Semiconductor, Inc.
* Copyright (C) 2011-2012 Google, Inc. * Copyright (C) 2011-2012 Google, Inc.
* *
* This file is subject to the terms and conditions of the GNU General Public * This file is subject to the terms and conditions of the GNU General Public
...@@ -39,11 +39,27 @@ const char product_id[] = "CYTRA"; ...@@ -39,11 +39,27 @@ const char product_id[] = "CYTRA";
static int cyapa_reinitialize(struct cyapa *cyapa); static int cyapa_reinitialize(struct cyapa *cyapa);
static inline bool cyapa_is_bootloader_mode(struct cyapa *cyapa) bool cyapa_is_pip_bl_mode(struct cyapa *cyapa)
{ {
if (cyapa->gen == CYAPA_GEN5 && cyapa->state == CYAPA_STATE_GEN5_BL) if (cyapa->gen == CYAPA_GEN5 && cyapa->state == CYAPA_STATE_GEN5_BL)
return true; return true;
return false;
}
bool cyapa_is_pip_app_mode(struct cyapa *cyapa)
{
if (cyapa->gen == CYAPA_GEN5 && cyapa->state == CYAPA_STATE_GEN5_APP)
return true;
return false;
}
static bool cyapa_is_bootloader_mode(struct cyapa *cyapa)
{
if (cyapa_is_pip_bl_mode(cyapa))
return true;
if (cyapa->gen == CYAPA_GEN3 && if (cyapa->gen == CYAPA_GEN3 &&
cyapa->state >= CYAPA_STATE_BL_BUSY && cyapa->state >= CYAPA_STATE_BL_BUSY &&
cyapa->state <= CYAPA_STATE_BL_ACTIVE) cyapa->state <= CYAPA_STATE_BL_ACTIVE)
...@@ -54,7 +70,7 @@ static inline bool cyapa_is_bootloader_mode(struct cyapa *cyapa) ...@@ -54,7 +70,7 @@ static inline bool cyapa_is_bootloader_mode(struct cyapa *cyapa)
static inline bool cyapa_is_operational_mode(struct cyapa *cyapa) static inline bool cyapa_is_operational_mode(struct cyapa *cyapa)
{ {
if (cyapa->gen == CYAPA_GEN5 && cyapa->state == CYAPA_STATE_GEN5_APP) if (cyapa_is_pip_app_mode(cyapa))
return true; return true;
if (cyapa->gen == CYAPA_GEN3 && cyapa->state == CYAPA_STATE_OP) if (cyapa->gen == CYAPA_GEN3 && cyapa->state == CYAPA_STATE_OP)
...@@ -306,7 +322,7 @@ static int cyapa_check_is_operational(struct cyapa *cyapa) ...@@ -306,7 +322,7 @@ static int cyapa_check_is_operational(struct cyapa *cyapa)
/* /*
* Returns 0 on device detected, negative errno on no device detected. * Returns 0 on device detected, negative errno on no device detected.
* And when the device is detected and opertaional, it will be reset to * And when the device is detected and operational, it will be reset to
* full power active mode automatically. * full power active mode automatically.
*/ */
static int cyapa_detect(struct cyapa *cyapa) static int cyapa_detect(struct cyapa *cyapa)
...@@ -629,15 +645,15 @@ static irqreturn_t cyapa_irq(int irq, void *dev_id) ...@@ -629,15 +645,15 @@ static irqreturn_t cyapa_irq(int irq, void *dev_id)
if (device_may_wakeup(dev)) if (device_may_wakeup(dev))
pm_wakeup_event(dev, 0); pm_wakeup_event(dev, 0);
/* Interrupt event maybe cuased by host command to trackpad device. */ /* Interrupt event can be caused by host command to trackpad device. */
if (cyapa->ops->irq_cmd_handler(cyapa)) { if (cyapa->ops->irq_cmd_handler(cyapa)) {
/* /*
* Interrupt event maybe from trackpad device input reporting. * Interrupt event maybe from trackpad device input reporting.
*/ */
if (!cyapa->input) { if (!cyapa->input) {
/* /*
* Still in probling or in firware image * Still in probing or in firmware image
* udpating or reading. * updating or reading.
*/ */
cyapa->ops->sort_empty_output_data(cyapa, cyapa->ops->sort_empty_output_data(cyapa,
NULL, NULL, NULL); NULL, NULL, NULL);
...@@ -1051,12 +1067,12 @@ static ssize_t cyapa_update_fw_store(struct device *dev, ...@@ -1051,12 +1067,12 @@ static ssize_t cyapa_update_fw_store(struct device *dev,
dev_dbg(dev, "firmware update successfully done.\n"); dev_dbg(dev, "firmware update successfully done.\n");
/* /*
* Redetect trackpad device states because firmware update process * Re-detect trackpad device states because firmware update process
* will reset trackpad device into bootloader mode. * will reset trackpad device into bootloader mode.
*/ */
ret = cyapa_reinitialize(cyapa); ret = cyapa_reinitialize(cyapa);
if (ret) { if (ret) {
dev_err(dev, "failed to redetect after updated: %d\n", ret); dev_err(dev, "failed to re-detect after updated: %d\n", ret);
error = error ? error : ret; error = error ? error : ret;
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Author: Dudley Du <dudl@cypress.com> * Author: Dudley Du <dudl@cypress.com>
* *
* Copyright (C) 2014 Cypress Semiconductor, Inc. * Copyright (C) 2014-2015 Cypress Semiconductor, Inc.
* *
* This file is subject to the terms and conditions of the GNU General Public * This file is subject to the terms and conditions of the GNU General Public
* License. See the file COPYING in the main directory of this archive for * License. See the file COPYING in the main directory of this archive for
...@@ -159,12 +159,86 @@ ...@@ -159,12 +159,86 @@
#define AUTOSUSPEND_DELAY 2000 /* unit : ms */ #define AUTOSUSPEND_DELAY 2000 /* unit : ms */
#define UNINIT_SLEEP_TIME 0xFFFF
#define UNINIT_PWR_MODE 0xFF
#define BTN_ONLY_MODE_NAME "buttononly" #define BTN_ONLY_MODE_NAME "buttononly"
#define OFF_MODE_NAME "off" #define OFF_MODE_NAME "off"
/* Common macros for PIP interface. */
#define PIP_HID_DESCRIPTOR_ADDR 0x0001
#define PIP_REPORT_DESCRIPTOR_ADDR 0x0002
#define PIP_INPUT_REPORT_ADDR 0x0003
#define PIP_OUTPUT_REPORT_ADDR 0x0004
#define PIP_CMD_DATA_ADDR 0x0006
#define PIP_RETRIEVE_DATA_STRUCTURE 0x24
#define PIP_CMD_CALIBRATE 0x28
#define PIP_BL_CMD_VERIFY_APP_INTEGRITY 0x31
#define PIP_BL_CMD_GET_BL_INFO 0x38
#define PIP_BL_CMD_PROGRAM_VERIFY_ROW 0x39
#define PIP_BL_CMD_LAUNCH_APP 0x3b
#define PIP_BL_CMD_INITIATE_BL 0x48
#define PIP_INVALID_CMD 0xff
#define PIP_HID_DESCRIPTOR_SIZE 32
#define PIP_HID_APP_REPORT_ID 0xf7
#define PIP_HID_BL_REPORT_ID 0xff
#define PIP_BL_CMD_REPORT_ID 0x40
#define PIP_BL_RESP_REPORT_ID 0x30
#define PIP_APP_CMD_REPORT_ID 0x2f
#define PIP_APP_RESP_REPORT_ID 0x1f
#define PIP_READ_SYS_INFO_CMD_LENGTH 7
#define PIP_BL_READ_APP_INFO_CMD_LENGTH 13
#define PIP_MIN_BL_CMD_LENGTH 13
#define PIP_MIN_BL_RESP_LENGTH 11
#define PIP_MIN_APP_CMD_LENGTH 7
#define PIP_MIN_APP_RESP_LENGTH 5
#define PIP_UNSUPPORTED_CMD_RESP_LENGTH 6
#define PIP_READ_SYS_INFO_RESP_LENGTH 71
#define PIP_BL_APP_INFO_RESP_LENGTH 30
#define PIP_BL_GET_INFO_RESP_LENGTH 19
#define PIP_PRODUCT_FAMILY_MASK 0xf000
#define PIP_PRODUCT_FAMILY_TRACKPAD 0x1000
#define PIP_DEEP_SLEEP_STATE_ON 0x00
#define PIP_DEEP_SLEEP_STATE_OFF 0x01
#define PIP_DEEP_SLEEP_STATE_MASK 0x03
#define PIP_APP_DEEP_SLEEP_REPORT_ID 0xf0
#define PIP_DEEP_SLEEP_RESP_LENGTH 5
#define PIP_DEEP_SLEEP_OPCODE 0x08
#define PIP_DEEP_SLEEP_OPCODE_MASK 0x0f
#define PIP_RESP_LENGTH_OFFSET 0
#define PIP_RESP_LENGTH_SIZE 2
#define PIP_RESP_REPORT_ID_OFFSET 2
#define PIP_RESP_RSVD_OFFSET 3
#define PIP_RESP_RSVD_KEY 0x00
#define PIP_RESP_BL_SOP_OFFSET 4
#define PIP_SOP_KEY 0x01 /* Start of Packet */
#define PIP_EOP_KEY 0x17 /* End of Packet */
#define PIP_RESP_APP_CMD_OFFSET 4
#define GET_PIP_CMD_CODE(reg) ((reg) & 0x7f)
#define PIP_RESP_STATUS_OFFSET 5
#define VALID_CMD_RESP_HEADER(resp, cmd) \
(((resp)[PIP_RESP_REPORT_ID_OFFSET] == PIP_APP_RESP_REPORT_ID) && \
((resp)[PIP_RESP_RSVD_OFFSET] == PIP_RESP_RSVD_KEY) && \
(GET_PIP_CMD_CODE((resp)[PIP_RESP_APP_CMD_OFFSET]) == (cmd)))
#define PIP_CMD_COMPLETE_SUCCESS(resp_data) \
((resp_data)[PIP_RESP_STATUS_OFFSET] == 0x00)
/* Variables to record latest gen5 trackpad power states. */
#define UNINIT_SLEEP_TIME 0xffff
#define UNINIT_PWR_MODE 0xff
#define PIP_DEV_SET_PWR_STATE(cyapa, s) ((cyapa)->dev_pwr_mode = (s))
#define PIP_DEV_GET_PWR_STATE(cyapa) ((cyapa)->dev_pwr_mode)
#define PIP_DEV_SET_SLEEP_TIME(cyapa, t) ((cyapa)->dev_sleep_time = (t))
#define PIP_DEV_GET_SLEEP_TIME(cyapa) ((cyapa)->dev_sleep_time)
#define PIP_DEV_UNINIT_SLEEP_TIME(cyapa) \
(((cyapa)->dev_sleep_time) == UNINIT_SLEEP_TIME)
/* The touch.id is used as the MT slot id, thus max MT slot is 15 */ /* The touch.id is used as the MT slot id, thus max MT slot is 15 */
#define CYAPA_MAX_MT_SLOTS 15 #define CYAPA_MAX_MT_SLOTS 15
...@@ -198,7 +272,7 @@ struct cyapa_dev_ops { ...@@ -198,7 +272,7 @@ struct cyapa_dev_ops {
int (*set_power_mode)(struct cyapa *, u8, u16); int (*set_power_mode)(struct cyapa *, u8, u16);
}; };
struct cyapa_gen5_cmd_states { struct cyapa_pip_cmd_states {
struct mutex cmd_lock; struct mutex cmd_lock;
struct completion cmd_ready; struct completion cmd_ready;
atomic_t cmd_issued; atomic_t cmd_issued;
...@@ -214,7 +288,7 @@ struct cyapa_gen5_cmd_states { ...@@ -214,7 +288,7 @@ struct cyapa_gen5_cmd_states {
}; };
union cyapa_cmd_states { union cyapa_cmd_states {
struct cyapa_gen5_cmd_states gen5; struct cyapa_pip_cmd_states pip;
}; };
enum cyapa_state { enum cyapa_state {
...@@ -259,7 +333,7 @@ struct cyapa { ...@@ -259,7 +333,7 @@ struct cyapa {
int physical_size_y; int physical_size_y;
/* Used in ttsp and truetouch based trackpad devices. */ /* Used in ttsp and truetouch based trackpad devices. */
u8 x_origin; /* X Axis Origin: 0 = left side; 1 = rigth side. */ u8 x_origin; /* X Axis Origin: 0 = left side; 1 = right side. */
u8 y_origin; /* Y Axis Origin: 0 = top; 1 = bottom. */ u8 y_origin; /* Y Axis Origin: 0 = top; 1 = bottom. */
int electrodes_x; /* Number of electrodes on the X Axis*/ int electrodes_x; /* Number of electrodes on the X Axis*/
int electrodes_y; /* Number of electrodes on the Y Axis*/ int electrodes_y; /* Number of electrodes on the Y Axis*/
...@@ -293,7 +367,47 @@ int cyapa_poll_state(struct cyapa *cyapa, unsigned int timeout); ...@@ -293,7 +367,47 @@ int cyapa_poll_state(struct cyapa *cyapa, unsigned int timeout);
u8 cyapa_sleep_time_to_pwr_cmd(u16 sleep_time); u8 cyapa_sleep_time_to_pwr_cmd(u16 sleep_time);
u16 cyapa_pwr_cmd_to_sleep_time(u8 pwr_mode); u16 cyapa_pwr_cmd_to_sleep_time(u8 pwr_mode);
ssize_t cyapa_i2c_pip_read(struct cyapa *cyapa, u8 *buf, size_t size);
ssize_t cyapa_i2c_pip_write(struct cyapa *cyapa, u8 *buf, size_t size);
int cyapa_empty_pip_output_data(struct cyapa *cyapa,
u8 *buf, int *len, cb_sort func);
int cyapa_i2c_pip_cmd_irq_sync(struct cyapa *cyapa,
u8 *cmd, int cmd_len,
u8 *resp_data, int *resp_len,
unsigned long timeout,
cb_sort func,
bool irq_mode);
int cyapa_pip_state_parse(struct cyapa *cyapa, u8 *reg_data, int len);
bool cyapa_pip_sort_system_info_data(struct cyapa *cyapa, u8 *buf, int len);
bool cyapa_sort_tsg_pip_bl_resp_data(struct cyapa *cyapa, u8 *data, int len);
int cyapa_pip_deep_sleep(struct cyapa *cyapa, u8 state);
bool cyapa_sort_tsg_pip_app_resp_data(struct cyapa *cyapa, u8 *data, int len);
int cyapa_pip_bl_exit(struct cyapa *cyapa);
int cyapa_pip_bl_enter(struct cyapa *cyapa);
bool cyapa_is_pip_bl_mode(struct cyapa *cyapa);
bool cyapa_is_pip_app_mode(struct cyapa *cyapa);
int cyapa_pip_cmd_state_initialize(struct cyapa *cyapa);
int cyapa_pip_resume_scanning(struct cyapa *cyapa);
int cyapa_pip_suspend_scanning(struct cyapa *cyapa);
int cyapa_pip_check_fw(struct cyapa *cyapa, const struct firmware *fw);
int cyapa_pip_bl_initiate(struct cyapa *cyapa, const struct firmware *fw);
int cyapa_pip_do_fw_update(struct cyapa *cyapa, const struct firmware *fw);
int cyapa_pip_bl_activate(struct cyapa *cyapa);
int cyapa_pip_bl_deactivate(struct cyapa *cyapa);
ssize_t cyapa_pip_do_calibrate(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count);
bool cyapa_pip_irq_cmd_handler(struct cyapa *cyapa);
int cyapa_pip_irq_handler(struct cyapa *cyapa);
extern u8 pip_read_sys_info[];
extern u8 pip_bl_read_app_info[];
extern const char product_id[]; extern const char product_id[];
extern const struct cyapa_dev_ops cyapa_gen3_ops; extern const struct cyapa_dev_ops cyapa_gen3_ops;
extern const struct cyapa_dev_ops cyapa_gen5_ops; extern const struct cyapa_dev_ops cyapa_gen5_ops;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Daniel Kurtz <djkurtz@chromium.org> * Daniel Kurtz <djkurtz@chromium.org>
* Benson Leung <bleung@chromium.org> * Benson Leung <bleung@chromium.org>
* *
* Copyright (C) 2011-2014 Cypress Semiconductor, Inc. * Copyright (C) 2011-2015 Cypress Semiconductor, Inc.
* Copyright (C) 2011-2012 Google, Inc. * Copyright (C) 2011-2012 Google, Inc.
* *
* This file is subject to the terms and conditions of the GNU General Public * This file is subject to the terms and conditions of the GNU General Public
...@@ -1156,7 +1156,7 @@ static bool cyapa_gen3_irq_cmd_handler(struct cyapa *cyapa) ...@@ -1156,7 +1156,7 @@ static bool cyapa_gen3_irq_cmd_handler(struct cyapa *cyapa)
* so, stop cyapa_gen3_irq_handler to continue process to * so, stop cyapa_gen3_irq_handler to continue process to
* avoid unwanted to error detecting and processing. * avoid unwanted to error detecting and processing.
* *
* And also, avoid the periodicly accerted interrupts to be processed * And also, avoid the periodically asserted interrupts to be processed
* as touch inputs when gen3 failed to launch into application mode, * as touch inputs when gen3 failed to launch into application mode,
* which will cause gen3 stays in bootloader mode. * which will cause gen3 stays in bootloader mode.
*/ */
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment