Revert "serial: max310x: make accessing revision id interface-agnostic"
This reverts commit 8082cc992d
which is
commit b3883ab5e95713e479f774ea68be275413e8e5b2 upstream.
It breaks the Android kernel abi and can be brought back in the future
in an abi-safe way if it is really needed.
Bug: 161946584
Change-Id: Ibe6d74a96dd665e39c32618207d2df190e769c67
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
@@ -72,7 +72,7 @@
|
|||||||
#define MAX310X_GLOBALCMD_REG MAX310X_REG_1F /* Global Command (WO) */
|
#define MAX310X_GLOBALCMD_REG MAX310X_REG_1F /* Global Command (WO) */
|
||||||
|
|
||||||
/* Extended registers */
|
/* Extended registers */
|
||||||
#define MAX310X_SPI_REVID_EXTREG MAX310X_REG_05 /* Revision ID */
|
#define MAX310X_REVID_EXTREG MAX310X_REG_05 /* Revision ID */
|
||||||
|
|
||||||
/* IRQ register bits */
|
/* IRQ register bits */
|
||||||
#define MAX310X_IRQ_LSR_BIT (1 << 0) /* LSR interrupt */
|
#define MAX310X_IRQ_LSR_BIT (1 << 0) /* LSR interrupt */
|
||||||
@@ -253,12 +253,6 @@
|
|||||||
#define MAX14830_BRGCFG_CLKDIS_BIT (1 << 6) /* Clock Disable */
|
#define MAX14830_BRGCFG_CLKDIS_BIT (1 << 6) /* Clock Disable */
|
||||||
#define MAX14830_REV_ID (0xb0)
|
#define MAX14830_REV_ID (0xb0)
|
||||||
|
|
||||||
struct max310x_if_cfg {
|
|
||||||
int (*extended_reg_enable)(struct device *dev, bool enable);
|
|
||||||
|
|
||||||
unsigned int rev_id_reg;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct max310x_devtype {
|
struct max310x_devtype {
|
||||||
char name[9];
|
char name[9];
|
||||||
int nr;
|
int nr;
|
||||||
@@ -281,7 +275,6 @@ struct max310x_one {
|
|||||||
|
|
||||||
struct max310x_port {
|
struct max310x_port {
|
||||||
const struct max310x_devtype *devtype;
|
const struct max310x_devtype *devtype;
|
||||||
const struct max310x_if_cfg *if_cfg;
|
|
||||||
struct regmap *regmap;
|
struct regmap *regmap;
|
||||||
struct clk *clk;
|
struct clk *clk;
|
||||||
#ifdef CONFIG_GPIOLIB
|
#ifdef CONFIG_GPIOLIB
|
||||||
@@ -371,12 +364,13 @@ static int max3109_detect(struct device *dev)
|
|||||||
unsigned int val = 0;
|
unsigned int val = 0;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = s->if_cfg->extended_reg_enable(dev, true);
|
ret = regmap_write(s->regmap, MAX310X_GLOBALCMD_REG,
|
||||||
|
MAX310X_EXTREG_ENBL);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
regmap_read(s->regmap, s->if_cfg->rev_id_reg, &val);
|
regmap_read(s->regmap, MAX310X_REVID_EXTREG, &val);
|
||||||
s->if_cfg->extended_reg_enable(dev, false);
|
regmap_write(s->regmap, MAX310X_GLOBALCMD_REG, MAX310X_EXTREG_DSBL);
|
||||||
if (((val & MAX310x_REV_MASK) != MAX3109_REV_ID)) {
|
if (((val & MAX310x_REV_MASK) != MAX3109_REV_ID)) {
|
||||||
dev_err(dev,
|
dev_err(dev,
|
||||||
"%s ID 0x%02x does not match\n", s->devtype->name, val);
|
"%s ID 0x%02x does not match\n", s->devtype->name, val);
|
||||||
@@ -401,12 +395,13 @@ static int max14830_detect(struct device *dev)
|
|||||||
unsigned int val = 0;
|
unsigned int val = 0;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = s->if_cfg->extended_reg_enable(dev, true);
|
ret = regmap_write(s->regmap, MAX310X_GLOBALCMD_REG,
|
||||||
|
MAX310X_EXTREG_ENBL);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
regmap_read(s->regmap, s->if_cfg->rev_id_reg, &val);
|
regmap_read(s->regmap, MAX310X_REVID_EXTREG, &val);
|
||||||
s->if_cfg->extended_reg_enable(dev, false);
|
regmap_write(s->regmap, MAX310X_GLOBALCMD_REG, MAX310X_EXTREG_DSBL);
|
||||||
if (((val & MAX310x_REV_MASK) != MAX14830_REV_ID)) {
|
if (((val & MAX310x_REV_MASK) != MAX14830_REV_ID)) {
|
||||||
dev_err(dev,
|
dev_err(dev,
|
||||||
"%s ID 0x%02x does not match\n", s->devtype->name, val);
|
"%s ID 0x%02x does not match\n", s->devtype->name, val);
|
||||||
@@ -1255,7 +1250,6 @@ static int max310x_gpio_set_config(struct gpio_chip *chip, unsigned int offset,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int max310x_probe(struct device *dev, const struct max310x_devtype *devtype,
|
static int max310x_probe(struct device *dev, const struct max310x_devtype *devtype,
|
||||||
const struct max310x_if_cfg *if_cfg,
|
|
||||||
struct regmap *regmaps[], int irq)
|
struct regmap *regmaps[], int irq)
|
||||||
{
|
{
|
||||||
int i, ret, fmin, fmax, freq;
|
int i, ret, fmin, fmax, freq;
|
||||||
@@ -1319,7 +1313,6 @@ static int max310x_probe(struct device *dev, const struct max310x_devtype *devty
|
|||||||
|
|
||||||
s->regmap = regmaps[0];
|
s->regmap = regmaps[0];
|
||||||
s->devtype = devtype;
|
s->devtype = devtype;
|
||||||
s->if_cfg = if_cfg;
|
|
||||||
dev_set_drvdata(dev, s);
|
dev_set_drvdata(dev, s);
|
||||||
|
|
||||||
/* Check device to ensure we are talking to what we expect */
|
/* Check device to ensure we are talking to what we expect */
|
||||||
@@ -1489,19 +1482,6 @@ static struct regmap_config regcfg = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CONFIG_SPI_MASTER
|
#ifdef CONFIG_SPI_MASTER
|
||||||
static int max310x_spi_extended_reg_enable(struct device *dev, bool enable)
|
|
||||||
{
|
|
||||||
struct max310x_port *s = dev_get_drvdata(dev);
|
|
||||||
|
|
||||||
return regmap_write(s->regmap, MAX310X_GLOBALCMD_REG,
|
|
||||||
enable ? MAX310X_EXTREG_ENBL : MAX310X_EXTREG_DSBL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct max310x_if_cfg __maybe_unused max310x_spi_if_cfg = {
|
|
||||||
.extended_reg_enable = max310x_spi_extended_reg_enable,
|
|
||||||
.rev_id_reg = MAX310X_SPI_REVID_EXTREG,
|
|
||||||
};
|
|
||||||
|
|
||||||
static int max310x_spi_probe(struct spi_device *spi)
|
static int max310x_spi_probe(struct spi_device *spi)
|
||||||
{
|
{
|
||||||
const struct max310x_devtype *devtype;
|
const struct max310x_devtype *devtype;
|
||||||
@@ -1528,7 +1508,7 @@ static int max310x_spi_probe(struct spi_device *spi)
|
|||||||
regmaps[i] = devm_regmap_init_spi(spi, ®cfg);
|
regmaps[i] = devm_regmap_init_spi(spi, ®cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return max310x_probe(&spi->dev, devtype, &max310x_spi_if_cfg, regmaps, spi->irq);
|
return max310x_probe(&spi->dev, devtype, regmaps, spi->irq);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int max310x_spi_remove(struct spi_device *spi)
|
static int max310x_spi_remove(struct spi_device *spi)
|
||||||
|
Reference in New Issue
Block a user