diff options
Diffstat (limited to 'drivers/nfc')
-rw-r--r-- | drivers/nfc/nfcmrvl/fw_dnld.c | 3 | ||||
-rw-r--r-- | drivers/nfc/pn533/pn533.c | 2 | ||||
-rw-r--r-- | drivers/nfc/pn533/uart.c | 2 | ||||
-rw-r--r-- | drivers/nfc/s3fwrn5/core.c | 2 | ||||
-rw-r--r-- | drivers/nfc/s3fwrn5/firmware.c | 2 | ||||
-rw-r--r-- | drivers/nfc/s3fwrn5/firmware.h | 2 | ||||
-rw-r--r-- | drivers/nfc/s3fwrn5/i2c.c | 2 | ||||
-rw-r--r-- | drivers/nfc/s3fwrn5/nci.c | 2 | ||||
-rw-r--r-- | drivers/nfc/s3fwrn5/nci.h | 2 | ||||
-rw-r--r-- | drivers/nfc/s3fwrn5/phy_common.c | 4 | ||||
-rw-r--r-- | drivers/nfc/s3fwrn5/phy_common.h | 4 | ||||
-rw-r--r-- | drivers/nfc/s3fwrn5/s3fwrn5.h | 2 | ||||
-rw-r--r-- | drivers/nfc/st-nci/ndlc.c | 4 | ||||
-rw-r--r-- | drivers/nfc/st-nci/se.c | 7 | ||||
-rw-r--r-- | drivers/nfc/st21nfca/se.c | 7 | ||||
-rw-r--r-- | drivers/nfc/trf7970a.c | 91 | ||||
-rw-r--r-- | drivers/nfc/virtual_ncidev.c | 2 |
17 files changed, 106 insertions, 34 deletions
diff --git a/drivers/nfc/nfcmrvl/fw_dnld.c b/drivers/nfc/nfcmrvl/fw_dnld.c index 43ce0c9b2355..a9b03dcc4100 100644 --- a/drivers/nfc/nfcmrvl/fw_dnld.c +++ b/drivers/nfc/nfcmrvl/fw_dnld.c @@ -119,7 +119,8 @@ static void fw_dnld_over(struct nfcmrvl_private *priv, u32 error) static void fw_dnld_timeout(struct timer_list *t) { - struct nfcmrvl_private *priv = from_timer(priv, t, fw_dnld.timer); + struct nfcmrvl_private *priv = timer_container_of(priv, t, + fw_dnld.timer); nfc_err(priv->dev, "FW loading timeout"); priv->fw_dnld.state = STATE_RESET; diff --git a/drivers/nfc/pn533/pn533.c b/drivers/nfc/pn533/pn533.c index 34c40d10e260..14661249c690 100644 --- a/drivers/nfc/pn533/pn533.c +++ b/drivers/nfc/pn533/pn533.c @@ -1233,7 +1233,7 @@ static int pn533_init_target_complete(struct pn533 *dev, struct sk_buff *resp) static void pn533_listen_mode_timer(struct timer_list *t) { - struct pn533 *dev = from_timer(dev, t, listen_timer); + struct pn533 *dev = timer_container_of(dev, t, listen_timer); dev->cancel_listen = 1; diff --git a/drivers/nfc/pn533/uart.c b/drivers/nfc/pn533/uart.c index 580c9193e4a7..a081bce61c29 100644 --- a/drivers/nfc/pn533/uart.c +++ b/drivers/nfc/pn533/uart.c @@ -133,7 +133,7 @@ static const struct pn533_phy_ops uart_phy_ops = { static void pn532_cmd_timeout(struct timer_list *t) { - struct pn532_uart_phy *dev = from_timer(dev, t, cmd_timeout); + struct pn532_uart_phy *dev = timer_container_of(dev, t, cmd_timeout); pn532_uart_send_frame(dev->priv, dev->cur_out_buf); } diff --git a/drivers/nfc/s3fwrn5/core.c b/drivers/nfc/s3fwrn5/core.c index aec356880adf..af0fa8bd970b 100644 --- a/drivers/nfc/s3fwrn5/core.c +++ b/drivers/nfc/s3fwrn5/core.c @@ -2,7 +2,7 @@ /* * NCI based driver for Samsung S3FWRN5 NFC chip * - * Copyright (C) 2015 Samsung Electrnoics + * Copyright (C) 2015 Samsung Electronics * Robert Baldyga <r.baldyga@samsung.com> */ diff --git a/drivers/nfc/s3fwrn5/firmware.c b/drivers/nfc/s3fwrn5/firmware.c index c20fdbac51c5..781cdbcac104 100644 --- a/drivers/nfc/s3fwrn5/firmware.c +++ b/drivers/nfc/s3fwrn5/firmware.c @@ -2,7 +2,7 @@ /* * NCI based driver for Samsung S3FWRN5 NFC chip * - * Copyright (C) 2015 Samsung Electrnoics + * Copyright (C) 2015 Samsung Electronics * Robert Baldyga <r.baldyga@samsung.com> */ diff --git a/drivers/nfc/s3fwrn5/firmware.h b/drivers/nfc/s3fwrn5/firmware.h index 3a82ce5837fb..19f479aa6920 100644 --- a/drivers/nfc/s3fwrn5/firmware.h +++ b/drivers/nfc/s3fwrn5/firmware.h @@ -2,7 +2,7 @@ /* * NCI based driver for Samsung S3FWRN5 NFC chip * - * Copyright (C) 2015 Samsung Electrnoics + * Copyright (C) 2015 Samsung Electronics * Robert Baldyga <r.baldyga@samsung.com> */ diff --git a/drivers/nfc/s3fwrn5/i2c.c b/drivers/nfc/s3fwrn5/i2c.c index 536c566e3f59..110d086cfe5b 100644 --- a/drivers/nfc/s3fwrn5/i2c.c +++ b/drivers/nfc/s3fwrn5/i2c.c @@ -2,7 +2,7 @@ /* * I2C Link Layer for Samsung S3FWRN5 NCI based Driver * - * Copyright (C) 2015 Samsung Electrnoics + * Copyright (C) 2015 Samsung Electronics * Robert Baldyga <r.baldyga@samsung.com> */ diff --git a/drivers/nfc/s3fwrn5/nci.c b/drivers/nfc/s3fwrn5/nci.c index ca6828f55ba0..5a9de11bbece 100644 --- a/drivers/nfc/s3fwrn5/nci.c +++ b/drivers/nfc/s3fwrn5/nci.c @@ -2,7 +2,7 @@ /* * NCI based driver for Samsung S3FWRN5 NFC chip * - * Copyright (C) 2015 Samsung Electrnoics + * Copyright (C) 2015 Samsung Electronics * Robert Baldyga <r.baldyga@samsung.com> */ diff --git a/drivers/nfc/s3fwrn5/nci.h b/drivers/nfc/s3fwrn5/nci.h index c2d906591e9e..bc4bce2bbc4d 100644 --- a/drivers/nfc/s3fwrn5/nci.h +++ b/drivers/nfc/s3fwrn5/nci.h @@ -2,7 +2,7 @@ /* * NCI based driver for Samsung S3FWRN5 NFC chip * - * Copyright (C) 2015 Samsung Electrnoics + * Copyright (C) 2015 Samsung Electronics * Robert Baldyga <r.baldyga@samsung.com> */ diff --git a/drivers/nfc/s3fwrn5/phy_common.c b/drivers/nfc/s3fwrn5/phy_common.c index 81318478d5fd..deb2c039f0fd 100644 --- a/drivers/nfc/s3fwrn5/phy_common.c +++ b/drivers/nfc/s3fwrn5/phy_common.c @@ -2,9 +2,9 @@ /* * Link Layer for Samsung S3FWRN5 NCI based Driver * - * Copyright (C) 2015 Samsung Electrnoics + * Copyright (C) 2015 Samsung Electronics * Robert Baldyga <r.baldyga@samsung.com> - * Copyright (C) 2020 Samsung Electrnoics + * Copyright (C) 2020 Samsung Electronics * Bongsu Jeon <bongsu.jeon@samsung.com> */ diff --git a/drivers/nfc/s3fwrn5/phy_common.h b/drivers/nfc/s3fwrn5/phy_common.h index 99749c9294d1..9cef25436bf9 100644 --- a/drivers/nfc/s3fwrn5/phy_common.h +++ b/drivers/nfc/s3fwrn5/phy_common.h @@ -2,9 +2,9 @@ * * Link Layer for Samsung S3FWRN5 NCI based Driver * - * Copyright (C) 2015 Samsung Electrnoics + * Copyright (C) 2015 Samsung Electronics * Robert Baldyga <r.baldyga@samsung.com> - * Copyright (C) 2020 Samsung Electrnoics + * Copyright (C) 2020 Samsung Electronics * Bongsu Jeon <bongsu.jeon@samsung.com> */ diff --git a/drivers/nfc/s3fwrn5/s3fwrn5.h b/drivers/nfc/s3fwrn5/s3fwrn5.h index bb8f936d13a2..2b492236090b 100644 --- a/drivers/nfc/s3fwrn5/s3fwrn5.h +++ b/drivers/nfc/s3fwrn5/s3fwrn5.h @@ -2,7 +2,7 @@ /* * NCI based driver for Samsung S3FWRN5 NFC chip * - * Copyright (C) 2015 Samsung Electrnoics + * Copyright (C) 2015 Samsung Electronics * Robert Baldyga <r.baldyga@samsung.com> */ diff --git a/drivers/nfc/st-nci/ndlc.c b/drivers/nfc/st-nci/ndlc.c index 8feac119a4bc..be4808859cfa 100644 --- a/drivers/nfc/st-nci/ndlc.c +++ b/drivers/nfc/st-nci/ndlc.c @@ -237,14 +237,14 @@ EXPORT_SYMBOL(ndlc_recv); static void ndlc_t1_timeout(struct timer_list *t) { - struct llt_ndlc *ndlc = from_timer(ndlc, t, t1_timer); + struct llt_ndlc *ndlc = timer_container_of(ndlc, t, t1_timer); schedule_work(&ndlc->sm_work); } static void ndlc_t2_timeout(struct timer_list *t) { - struct llt_ndlc *ndlc = from_timer(ndlc, t, t2_timer); + struct llt_ndlc *ndlc = timer_container_of(ndlc, t, t2_timer); schedule_work(&ndlc->sm_work); } diff --git a/drivers/nfc/st-nci/se.c b/drivers/nfc/st-nci/se.c index 8cfe5405bae6..607ec768eb7b 100644 --- a/drivers/nfc/st-nci/se.c +++ b/drivers/nfc/st-nci/se.c @@ -696,7 +696,8 @@ static void st_nci_se_wt_timeout(struct timer_list *t) */ /* hardware reset managed through VCC_UICC_OUT power supply */ u8 param = 0x01; - struct st_nci_info *info = from_timer(info, t, se_info.bwi_timer); + struct st_nci_info *info = timer_container_of(info, t, + se_info.bwi_timer); info->se_info.bwi_active = false; @@ -714,8 +715,8 @@ static void st_nci_se_wt_timeout(struct timer_list *t) static void st_nci_se_activation_timeout(struct timer_list *t) { - struct st_nci_info *info = from_timer(info, t, - se_info.se_active_timer); + struct st_nci_info *info = timer_container_of(info, t, + se_info.se_active_timer); info->se_info.se_active = false; diff --git a/drivers/nfc/st21nfca/se.c b/drivers/nfc/st21nfca/se.c index 9a50f3c03bd4..7154bc1d644a 100644 --- a/drivers/nfc/st21nfca/se.c +++ b/drivers/nfc/st21nfca/se.c @@ -280,15 +280,16 @@ static void st21nfca_se_wt_work(struct work_struct *work) static void st21nfca_se_wt_timeout(struct timer_list *t) { - struct st21nfca_hci_info *info = from_timer(info, t, se_info.bwi_timer); + struct st21nfca_hci_info *info = timer_container_of(info, t, + se_info.bwi_timer); schedule_work(&info->se_info.timeout_work); } static void st21nfca_se_activation_timeout(struct timer_list *t) { - struct st21nfca_hci_info *info = from_timer(info, t, - se_info.se_active_timer); + struct st21nfca_hci_info *info = timer_container_of(info, t, + se_info.se_active_timer); info->se_info.se_active = false; diff --git a/drivers/nfc/trf7970a.c b/drivers/nfc/trf7970a.c index 9e1a34e23af2..d17c701c7888 100644 --- a/drivers/nfc/trf7970a.c +++ b/drivers/nfc/trf7970a.c @@ -272,12 +272,18 @@ #define TRF7970A_MODULATOR_EN_OOK BIT(6) #define TRF7970A_MODULATOR_27MHZ BIT(7) +#define TRF7970A_RX_GAIN_REDUCTION_MAX_DB 15 +#define TRF7970A_RX_GAIN_REDUCTION_DB_PER_LSB 5 #define TRF7970A_RX_SPECIAL_SETTINGS_NO_LIM BIT(0) #define TRF7970A_RX_SPECIAL_SETTINGS_AGCR BIT(1) -#define TRF7970A_RX_SPECIAL_SETTINGS_GD_0DB (0x0 << 2) -#define TRF7970A_RX_SPECIAL_SETTINGS_GD_5DB (0x1 << 2) -#define TRF7970A_RX_SPECIAL_SETTINGS_GD_10DB (0x2 << 2) -#define TRF7970A_RX_SPECIAL_SETTINGS_GD_15DB (0x3 << 2) +#define TRF7970A_RX_SPECIAL_SETTINGS_GD_SHIFT 2 +#define TRF7970A_RX_SPECIAL_SETTINGS_GD_MAX (0x3) +#define TRF7970A_RX_SPECIAL_SETTINGS_GD_MASK (TRF7970A_RX_SPECIAL_SETTINGS_GD_MAX << \ + TRF7970A_RX_SPECIAL_SETTINGS_GD_SHIFT) +#define TRF7970A_RX_SPECIAL_SETTINGS_GD_0DB (0x0 << TRF7970A_RX_SPECIAL_SETTINGS_GD_SHIFT) +#define TRF7970A_RX_SPECIAL_SETTINGS_GD_5DB (0x1 << TRF7970A_RX_SPECIAL_SETTINGS_GD_SHIFT) +#define TRF7970A_RX_SPECIAL_SETTINGS_GD_10DB (0x2 << TRF7970A_RX_SPECIAL_SETTINGS_GD_SHIFT) +#define TRF7970A_RX_SPECIAL_SETTINGS_GD_15DB (0x3 << TRF7970A_RX_SPECIAL_SETTINGS_GD_SHIFT) #define TRF7970A_RX_SPECIAL_SETTINGS_HBT BIT(4) #define TRF7970A_RX_SPECIAL_SETTINGS_M848 BIT(5) #define TRF7970A_RX_SPECIAL_SETTINGS_C424 BIT(6) @@ -452,6 +458,8 @@ struct trf7970a { unsigned int timeout; bool ignore_timeout; struct delayed_work timeout_work; + u8 rx_gain_reduction; + bool custom_rx_gain_reduction; }; static int trf7970a_cmd(struct trf7970a *trf, u8 opcode) @@ -551,6 +559,41 @@ static int trf7970a_read_irqstatus(struct trf7970a *trf, u8 *status) return ret; } +static int trf7970a_update_rx_gain_reduction(struct trf7970a *trf) +{ + int ret = 0; + u8 reg; + + if (!trf->custom_rx_gain_reduction) + return 0; + + ret = trf7970a_read(trf, TRF7970A_RX_SPECIAL_SETTINGS, ®); + if (ret) + return ret; + reg &= ~(TRF7970A_RX_SPECIAL_SETTINGS_GD_MASK); + reg |= trf->rx_gain_reduction; + + ret = trf7970a_write(trf, TRF7970A_RX_SPECIAL_SETTINGS, reg); + + return ret; +} + +static int trf7970a_update_iso_ctrl_register(struct trf7970a *trf, u8 iso_ctrl) +{ + int ret; + + ret = trf7970a_write(trf, TRF7970A_ISO_CTRL, iso_ctrl); + if (ret) + return ret; + /* + * Every time the ISO_CTRL register is written, the RX special setting register is reset by + * the chip. When a custom gain reguduction is required, it should be rewritten now. + */ + ret = trf7970a_update_rx_gain_reduction(trf); + + return ret; +} + static int trf7970a_read_target_proto(struct trf7970a *trf, u8 *target_proto) { int ret; @@ -930,8 +973,7 @@ static irqreturn_t trf7970a_irq(int irq, void *dev_id) } if (iso_ctrl != trf->iso_ctrl) { - ret = trf7970a_write(trf, TRF7970A_ISO_CTRL, - iso_ctrl); + ret = trf7970a_update_iso_ctrl_register(trf, iso_ctrl); if (ret) goto err_unlock_exit; @@ -1035,6 +1077,11 @@ static int trf7970a_init(struct trf7970a *trf) if (ret) goto err_out; + /* Set the gain reduction after soft init */ + ret = trf7970a_update_rx_gain_reduction(trf); + if (ret) + goto err_out; + ret = trf7970a_cmd(trf, TRF7970A_CMD_IDLE); if (ret) goto err_out; @@ -1309,7 +1356,7 @@ static int trf7970a_in_config_framing(struct trf7970a *trf, int framing) } if (iso_ctrl != trf->iso_ctrl) { - ret = trf7970a_write(trf, TRF7970A_ISO_CTRL, iso_ctrl); + ret = trf7970a_update_iso_ctrl_register(trf, iso_ctrl); if (ret) return ret; @@ -1441,7 +1488,7 @@ static int trf7970a_per_cmd_config(struct trf7970a *trf, } if (iso_ctrl != trf->iso_ctrl) { - ret = trf7970a_write(trf, TRF7970A_ISO_CTRL, iso_ctrl); + ret = trf7970a_update_iso_ctrl_register(trf, iso_ctrl); if (ret) return ret; @@ -1605,8 +1652,7 @@ static int trf7970a_tg_config_rf_tech(struct trf7970a *trf, int tech) */ if ((trf->framing == NFC_DIGITAL_FRAMING_NFC_DEP_ACTIVATED) && (trf->iso_ctrl_tech != trf->iso_ctrl)) { - ret = trf7970a_write(trf, TRF7970A_ISO_CTRL, - trf->iso_ctrl_tech); + ret = trf7970a_update_iso_ctrl_register(trf, trf->iso_ctrl_tech); trf->iso_ctrl = trf->iso_ctrl_tech; } @@ -1654,7 +1700,7 @@ static int trf7970a_tg_config_framing(struct trf7970a *trf, int framing) trf->framing = framing; if (iso_ctrl != trf->iso_ctrl) { - ret = trf7970a_write(trf, TRF7970A_ISO_CTRL, iso_ctrl); + ret = trf7970a_update_iso_ctrl_register(trf, iso_ctrl); if (ret) return ret; @@ -1755,6 +1801,10 @@ static int _trf7970a_tg_listen(struct nfc_digital_dev *ddev, u16 timeout, if (ret) goto out_err; + ret = trf7970a_update_rx_gain_reduction(trf); + if (ret) + goto out_err; + ret = trf7970a_write(trf, TRF7970A_REG_IO_CTRL, trf->io_ctrl | TRF7970A_REG_IO_CTRL_VRS(0x1)); if (ret) @@ -1945,6 +1995,10 @@ static int trf7970a_startup(struct trf7970a *trf) if (ret) return ret; + ret = trf7970a_update_rx_gain_reduction(trf); + if (ret) + return ret; + pm_runtime_set_active(trf->dev); pm_runtime_enable(trf->dev); pm_runtime_mark_last_busy(trf->dev); @@ -1993,6 +2047,7 @@ static int trf7970a_probe(struct spi_device *spi) struct trf7970a *trf; int uvolts, autosuspend_delay, ret; u32 clk_freq = TRF7970A_13MHZ_CLOCK_FREQUENCY; + u32 rx_gain_reduction_db; if (!np) { dev_err(&spi->dev, "No Device Tree entry\n"); @@ -2054,6 +2109,20 @@ static int trf7970a_probe(struct spi_device *spi) trf->modulator_sys_clk_ctrl = 0; } + if (of_property_read_u32(np, "ti,rx-gain-reduction-db", &rx_gain_reduction_db) == 0) { + if (rx_gain_reduction_db > TRF7970A_RX_GAIN_REDUCTION_MAX_DB) { + dev_warn(trf->dev, "RX Gain reduction too high. Ignored\n"); + } else if ((rx_gain_reduction_db % TRF7970A_RX_GAIN_REDUCTION_DB_PER_LSB)) { + dev_warn(trf->dev, "RX Gain must be set in 5 dB increments. Ignored\n"); + } else { + dev_dbg(trf->dev, "RX gain set to -%udB\n", rx_gain_reduction_db); + trf->rx_gain_reduction = ((rx_gain_reduction_db / + TRF7970A_RX_GAIN_REDUCTION_DB_PER_LSB) << + TRF7970A_RX_SPECIAL_SETTINGS_GD_SHIFT); + trf->custom_rx_gain_reduction = true; + } + } + ret = devm_request_threaded_irq(trf->dev, spi->irq, NULL, trf7970a_irq, IRQF_TRIGGER_RISING | IRQF_ONESHOT, diff --git a/drivers/nfc/virtual_ncidev.c b/drivers/nfc/virtual_ncidev.c index 6b89d596ba9a..9ef8ef2d4363 100644 --- a/drivers/nfc/virtual_ncidev.c +++ b/drivers/nfc/virtual_ncidev.c @@ -2,7 +2,7 @@ /* * Virtual NCI device simulation driver * - * Copyright (C) 2020 Samsung Electrnoics + * Copyright (C) 2020 Samsung Electronics * Bongsu Jeon <bongsu.jeon@samsung.com> */ |