/*! \file sx932x.c\r
* \brief SX9320 Driver\r
*\r
- * Driver for the SX9320 \r
+ * Driver for the SX9320\r
* Copyright (c) 2011 Semtech Corp\r
*\r
* This program is free software; you can redistribute it and/or modify\r
#include <linux/syscalls.h>\r
#include <linux/wakelock.h>\r
#include <linux/uaccess.h>\r
-#include <linux/sort.h> \r
+#include <linux/sort.h>\r
#include <linux/gpio.h>\r
#include <linux/of_gpio.h>\r
#include <linux/regulator/consumer.h>\r
\r
/*! \fn static int write_register(psx93XX_t this, u8 address, u8 value)\r
* \brief Sends a write register to the device\r
- * \param this Pointer to main parent struct \r
+ * \param this Pointer to main parent struct\r
* \param address 8-bit register address\r
* \param value 8-bit register value to write to address\r
* \return Value from i2c_master_send\r
return returnValue;\r
}\r
\r
-/*! \fn static int read_register(psx93XX_t this, u8 address, u8 *value) \r
+/*! \fn static int read_register(psx93XX_t this, u8 address, u8 *value)\r
* \brief Reads a register's value from the device\r
-* \param this Pointer to main parent struct \r
+* \param this Pointer to main parent struct\r
* \param address 8-Bit address to read from\r
-* \param value Pointer to 8-bit value to save register value to \r
+* \param value Pointer to 8-bit value to save register value to\r
* \return Value from i2c_smbus_read_byte_data if < 0. else 0\r
*/\r
static int read_register(psx93XX_t this, u8 address, u8 *value)\r
dev_info(&i2c->dev, "read_register Address:i2c:%s 0x%x Return: 0x%x\n",this->bus,\r
address,returnValue);\r
returnValue = i2c_smbus_read_byte_data(i2c,address);\r
- \r
+\r
#ifdef DEBUG\r
dev_info(&i2c->dev, "read_register Address: 0x%x Return: 0x%x\n",\r
address,returnValue);\r
if (returnValue >= 0) {\r
*value = returnValue;\r
return 0;\r
- } \r
+ }\r
else {\r
return returnValue;\r
}\r
/*! \fn static int read_regStat(psx93XX_t this)\r
* \brief Shortcut to read what caused interrupt.\r
* \details This is to keep the drivers a unified\r
- * function that will read whatever register(s) \r
+ * function that will read whatever register(s)\r
* provide information on why the interrupt was caused.\r
- * \param this Pointer to main parent struct \r
+ * \param this Pointer to main parent struct\r
* \return If successful, Value of bit(s) that cause interrupt, else 0\r
*/\r
static int read_regStat(psx93XX_t this)\r
u8 failcode;\r
u8 loop = 0;\r
this->failStatusCode = 0;\r
- \r
+\r
//Check th IRQ Status\r
while(this->get_nirq_low && this->get_nirq_low()){\r
read_regStat(this);\r
break;\r
}\r
}\r
- \r
+\r
//Check I2C Connection\r
ret = read_register(this, SX932x_WHOAMI_REG, &failcode);\r
if(ret < 0){\r
this->failStatusCode = SX932x_I2C_ERROR;\r
}\r
- \r
+\r
if(failcode!= SX932x_WHOAMI_VALUE){\r
this->failStatusCode = SX932x_ID_ERROR;\r
}\r
- \r
+\r
dev_info(this->pdev, "sx932x failcode = 0x%x\n",this->failStatusCode);\r
return (int)this->failStatusCode;\r
}\r
u16 offset;\r
if(this){\r
for(csx =0; csx<4; csx++){\r
- write_register(this,SX932x_CPSRD,csx);//here to check the CS1, also can read other channel \r
+ write_register(this,SX932x_CPSRD,csx);//here to check the CS1, also can read other channel\r
read_register(this,SX932x_USEMSB,&msb);\r
read_register(this,SX932x_USELSB,&lsb);\r
useful = (s32)((msb << 8) | lsb);\r
- \r
+\r
read_register(this,SX932x_AVGMSB,&msb);\r
read_register(this,SX932x_AVGLSB,&lsb);\r
average = (s32)((msb << 8) | lsb);\r
- \r
+\r
read_register(this,SX932x_DIFFMSB,&msb);\r
read_register(this,SX932x_DIFFLSB,&lsb);\r
diff = (s32)((msb << 8) | lsb);\r
- \r
+\r
read_register(this,SX932x_OFFSETMSB,&msb);\r
read_register(this,SX932x_OFFSETLSB,&lsb);\r
offset = (u16)((msb << 8) | lsb);\r
psx932x_t pDevice = 0;\r
psx932x_platform_data_t pdata = 0;\r
int i = 0;\r
- /* configure device */ \r
+ /* configure device */\r
dev_info(this->pdev, "Going to Setup I2C Registers\n");\r
if (this && (pDevice = this->pDevice) && (pdata = pDevice->hw))\r
{\r
\r
/*! \fn static int initialize(psx93XX_t this)\r
* \brief Performs all initialization needed to configure the device\r
- * \param this Pointer to main parent struct \r
+ * \param this Pointer to main parent struct\r
* \return Last used command's return value (negative if error)\r
*/\r
static int initialize(psx93XX_t this)\r
dev_info(this->pdev, "Sent Software Reset. Waiting until device is back from reset to continue.\n");\r
/* just sleep for awhile instead of using a loop with reading irq status */\r
msleep(100);\r
- \r
+\r
ret = sx932x_global_variable_init(this);\r
- \r
+\r
sx932x_reg_init(this);\r
msleep(100); /* make sure everything is running */\r
manual_offset_calibration(this);\r
\r
/* re-enable interrupt handling */\r
enable_irq(this->irq);\r
- \r
+\r
/* make sure no interrupts are pending since enabling irq will only\r
* work on next falling edge */\r
read_regStat(this);\r
return -ENOMEM;\r
}\r
\r
-/*! \r
+/*!\r
* \brief Handle what to do when a touch occurs\r
- * \param this Pointer to main parent struct \r
+ * \param this Pointer to main parent struct\r
*/\r
static void touchProcess(psx93XX_t this)\r
{\r
{\r
struct device_node *dNode = dev->of_node;\r
enum of_gpio_flags flags;\r
- int ret;\r
if (dNode == NULL)\r
return -ENODEV;\r
- \r
+\r
pdata->irq_gpio= of_get_named_gpio_flags(dNode,\r
"Semtech,nirq-gpio", 0, &flags);\r
irq_gpio_num = pdata->irq_gpio;\r
pr_err("[SENSOR]: %s - get irq_gpio error\n", __func__);\r
return -ENODEV;\r
}\r
- \r
+\r
/***********************************************************************/\r
// load in registers from device tree\r
of_property_read_u32(dNode,"Semtech,reg-num",&pdata->i2c_reg_num);\r
return rc;\r
}\r
pinctrl_int = devm_pinctrl_get_select(this->pdev, "default");\r
- \r
+\r
this->irq = client->irq = gpio_to_irq(pdata->irq_gpio);\r
}\r
else {\r
else {\r
pr_err("[SX9320] : %s - Do not init platform HW", __func__);\r
}\r
- \r
+\r
pr_err("[SX9320]: %s - sx9320_irq_debug\n",__func__);\r
return rc;\r
}\r
* \return Whether probe was successful\r
*/\r
static int sx932x_probe(struct i2c_client *client, const struct i2c_device_id *id)\r
-{ \r
+{\r
int i = 0;\r
int err = 0;\r
int ret = 0;\r
- u8 data1 = 0;\r
- int q = 0;\r
psx93XX_t this = 0;\r
psx932x_t pDevice = 0;\r
psx932x_platform_data_t pplatData = 0;\r
}\r
pplatData->get_is_nirq_low = sx932x_get_nirq_state;\r
pplatData->pbuttonInformation = pButtonInformationData;\r
- \r
- client->dev.platform_data = pplatData; \r
+\r
+ client->dev.platform_data = pplatData;\r
err = sx932x_parse_dt(pplatData, &client->dev);\r
if (err) {\r
dev_err(&client->dev, "could not setup pin\n");\r
\r
pplatData->init_platform_hw = sx932x_init_platform_hw;\r
dev_err(&client->dev, "SX9320 init_platform_hw done!\n");\r
- \r
+\r
if (this){\r
dev_info(&client->dev, "SX9320 initialize start!!");\r
- /* In case we need to reinitialize data \r
+ /* In case we need to reinitialize data\r
* (e.q. if suspend reset device) */\r
this->init = initialize;\r
/* shortcut to read status of interrupt */\r
this->refreshStatus = read_regStat;\r
- /* pointer to function from platform data to get pendown \r
+ /* pointer to function from platform data to get pendown\r
* (1->NIRQ=0, 0->NIRQ=1) */\r
this->get_nirq_low = pplatData->get_is_nirq_low;\r
/* save irq in case we need to reference it */\r
status = this->refreshStatus(this);\r
counter = -1;\r
dev_dbg(this->pdev, "Worker - Refresh Status %d\n",status);\r
- \r
+\r
while((++counter) < MAX_NUM_STATUS_BITS) { /* counter start from MSB */\r
if (((status>>counter) & 0x01) && (this->statusFunc[counter])) {\r
dev_info(this->pdev, "SX9320 Function Pointer Found. Calling\n");\r