Skip to content

Commit 40f4b05

Browse files
committed
Merge remote-tracking branch 'regmap/for-6.3' into regmap-next
2 parents 697c389 + c74e7af commit 40f4b05

File tree

3 files changed

+35
-50
lines changed

3 files changed

+35
-50
lines changed

drivers/base/regmap/regmap-irq.c

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,8 @@ static void regmap_irq_sync_unlock(struct irq_data *data)
189189
if (!d->type_buf_def[i])
190190
continue;
191191
reg = d->get_irq_reg(d, d->chip->type_base, i);
192-
if (d->chip->type_invert)
193-
ret = regmap_update_bits(d->map, reg,
194-
d->type_buf_def[i], ~d->type_buf[i]);
195-
else
196-
ret = regmap_update_bits(d->map, reg,
197-
d->type_buf_def[i], d->type_buf[i]);
192+
ret = regmap_update_bits(d->map, reg,
193+
d->type_buf_def[i], d->type_buf[i]);
198194
if (ret != 0)
199195
dev_err(d->map->dev, "Failed to sync type in %x\n",
200196
reg);
@@ -882,20 +878,6 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
882878
*/
883879
dev_warn(map->dev, "mask_base and unmask_base are inverted, please fix it");
884880

885-
/* Might as well warn about mask_invert while we're at it... */
886-
if (chip->mask_invert)
887-
dev_warn(map->dev, "mask_invert=true ignored");
888-
889-
d->mask_base = chip->unmask_base;
890-
d->unmask_base = chip->mask_base;
891-
} else if (chip->mask_invert) {
892-
/*
893-
* Swap the roles of mask_base and unmask_base if the bits are
894-
* inverted. This is deprecated, drivers should use unmask_base
895-
* directly.
896-
*/
897-
dev_warn(map->dev, "mask_invert=true is deprecated; please switch to unmask_base");
898-
899881
d->mask_base = chip->unmask_base;
900882
d->unmask_base = chip->mask_base;
901883
} else {
@@ -1028,9 +1010,6 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
10281010

10291011
ret = regmap_read(map, reg, &d->type_buf_def[i]);
10301012

1031-
if (d->chip->type_invert)
1032-
d->type_buf_def[i] = ~d->type_buf_def[i];
1033-
10341013
if (ret) {
10351014
dev_err(map->dev, "Failed to get type defaults at 0x%x: %d\n",
10361015
reg, ret);

drivers/base/regmap/regmap-mdio.c

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,21 @@
1010
/* Clause-45 mask includes the device type (5 bit) and actual register number (16 bit) */
1111
#define REGNUM_C45_MASK GENMASK(20, 0)
1212

13-
static int regmap_mdio_read(struct mdio_device *mdio_dev, u32 reg, unsigned int *val)
13+
static int regmap_mdio_c22_read(void *context, unsigned int reg, unsigned int *val)
1414
{
15+
struct mdio_device *mdio_dev = context;
1516
int ret;
1617

18+
if (unlikely(reg & ~REGNUM_C22_MASK))
19+
return -ENXIO;
20+
1721
ret = mdiodev_read(mdio_dev, reg);
1822
if (ret < 0)
1923
return ret;
2024

2125
*val = ret & REGVAL_MASK;
22-
return 0;
23-
}
24-
25-
static int regmap_mdio_write(struct mdio_device *mdio_dev, u32 reg, unsigned int val)
26-
{
27-
return mdiodev_write(mdio_dev, reg, val);
28-
}
29-
30-
static int regmap_mdio_c22_read(void *context, unsigned int reg, unsigned int *val)
31-
{
32-
struct mdio_device *mdio_dev = context;
33-
34-
if (unlikely(reg & ~REGNUM_C22_MASK))
35-
return -ENXIO;
3626

37-
return regmap_mdio_read(mdio_dev, reg, val);
27+
return 0;
3828
}
3929

4030
static int regmap_mdio_c22_write(void *context, unsigned int reg, unsigned int val)
@@ -55,21 +45,36 @@ static const struct regmap_bus regmap_mdio_c22_bus = {
5545
static int regmap_mdio_c45_read(void *context, unsigned int reg, unsigned int *val)
5646
{
5747
struct mdio_device *mdio_dev = context;
48+
unsigned int devad;
49+
int ret;
5850

5951
if (unlikely(reg & ~REGNUM_C45_MASK))
6052
return -ENXIO;
6153

62-
return regmap_mdio_read(mdio_dev, MII_ADDR_C45 | reg, val);
54+
devad = reg >> REGMAP_MDIO_C45_DEVAD_SHIFT;
55+
reg = reg & REGMAP_MDIO_C45_REGNUM_MASK;
56+
57+
ret = mdiodev_c45_read(mdio_dev, devad, reg);
58+
if (ret < 0)
59+
return ret;
60+
61+
*val = ret & REGVAL_MASK;
62+
63+
return 0;
6364
}
6465

6566
static int regmap_mdio_c45_write(void *context, unsigned int reg, unsigned int val)
6667
{
6768
struct mdio_device *mdio_dev = context;
69+
unsigned int devad;
6870

6971
if (unlikely(reg & ~REGNUM_C45_MASK))
7072
return -ENXIO;
7173

72-
return regmap_mdio_write(mdio_dev, MII_ADDR_C45 | reg, val);
74+
devad = reg >> REGMAP_MDIO_C45_DEVAD_SHIFT;
75+
reg = reg & REGMAP_MDIO_C45_REGNUM_MASK;
76+
77+
return mdiodev_c45_write(mdio_dev, devad, reg, val);
7378
}
7479

7580
static const struct regmap_bus regmap_mdio_c45_bus = {

include/linux/regmap.h

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ struct regmap_field;
3838
struct snd_ac97;
3939
struct sdw_slave;
4040

41+
/*
42+
* regmap_mdio address encoding. IEEE 802.3ae clause 45 addresses consist of a
43+
* device address and a register address.
44+
*/
45+
#define REGMAP_MDIO_C45_DEVAD_SHIFT 16
46+
#define REGMAP_MDIO_C45_DEVAD_MASK GENMASK(20, 16)
47+
#define REGMAP_MDIO_C45_REGNUM_MASK GENMASK(15, 0)
48+
4149
/* An enum of all the supported cache types */
4250
enum regcache_type {
4351
REGCACHE_NONE,
@@ -512,6 +520,7 @@ typedef void (*regmap_hw_free_context)(void *context);
512520
* to perform locking. This field is ignored if custom lock/unlock
513521
* functions are used (see fields lock/unlock of
514522
* struct regmap_config).
523+
* @free_on_exit: kfree this on exit of regmap
515524
* @write: Write operation.
516525
* @gather_write: Write operation with split register/value, return -ENOTSUPP
517526
* if not implemented on a given device.
@@ -540,10 +549,10 @@ typedef void (*regmap_hw_free_context)(void *context);
540549
* DEFAULT, BIG is assumed.
541550
* @max_raw_read: Max raw read size that can be used on the bus.
542551
* @max_raw_write: Max raw write size that can be used on the bus.
543-
* @free_on_exit: kfree this on exit of regmap
544552
*/
545553
struct regmap_bus {
546554
bool fast_io;
555+
bool free_on_exit;
547556
regmap_hw_write write;
548557
regmap_hw_gather_write gather_write;
549558
regmap_hw_async_write async_write;
@@ -560,7 +569,6 @@ struct regmap_bus {
560569
enum regmap_endian val_format_endian_default;
561570
size_t max_raw_read;
562571
size_t max_raw_write;
563-
bool free_on_exit;
564572
};
565573

566574
/*
@@ -1532,9 +1540,6 @@ struct regmap_irq_chip_data;
15321540
* @config_base: Base address for IRQ type config regs. If null unsupported.
15331541
* @irq_reg_stride: Stride to use for chips where registers are not contiguous.
15341542
* @init_ack_masked: Ack all masked interrupts once during initalization.
1535-
* @mask_invert: Inverted mask register: cleared bits are masked out.
1536-
* Deprecated; prefer describing an inverted mask register as
1537-
* an unmask register.
15381543
* @mask_unmask_non_inverted: Controls mask bit inversion for chips that set
15391544
* both @mask_base and @unmask_base. If false, mask and unmask bits are
15401545
* inverted (which is deprecated behavior); if true, bits will not be
@@ -1547,8 +1552,6 @@ struct regmap_irq_chip_data;
15471552
* @ack_invert: Inverted ack register: cleared bits for ack.
15481553
* @clear_ack: Use this to set 1 and 0 or vice-versa to clear interrupts.
15491554
* @wake_invert: Inverted wake register: cleared bits are wake enabled.
1550-
* @type_invert: Invert the type flags. Deprecated, use config registers
1551-
* instead.
15521555
* @type_in_mask: Use the mask registers for controlling irq type. Use this if
15531556
* the hardware provides separate bits for rising/falling edge
15541557
* or low/high level interrupts and they should be combined into
@@ -1618,14 +1621,12 @@ struct regmap_irq_chip {
16181621
const unsigned int *config_base;
16191622
unsigned int irq_reg_stride;
16201623
unsigned int init_ack_masked:1;
1621-
unsigned int mask_invert:1;
16221624
unsigned int mask_unmask_non_inverted:1;
16231625
unsigned int use_ack:1;
16241626
unsigned int ack_invert:1;
16251627
unsigned int clear_ack:1;
16261628
unsigned int wake_invert:1;
16271629
unsigned int runtime_pm:1;
1628-
unsigned int type_invert:1;
16291630
unsigned int type_in_mask:1;
16301631
unsigned int clear_on_unmask:1;
16311632
unsigned int not_fixed_stride:1;

0 commit comments

Comments
 (0)