| .. | .. |
|---|
| 21 | 21 | ocelot->map[target][reg & REG_MASK] + offset, &val); |
|---|
| 22 | 22 | return val; |
|---|
| 23 | 23 | } |
|---|
| 24 | | -EXPORT_SYMBOL(__ocelot_read_ix); |
|---|
| 24 | +EXPORT_SYMBOL_GPL(__ocelot_read_ix); |
|---|
| 25 | 25 | |
|---|
| 26 | 26 | void __ocelot_write_ix(struct ocelot *ocelot, u32 val, u32 reg, u32 offset) |
|---|
| 27 | 27 | { |
|---|
| .. | .. |
|---|
| 32 | 32 | regmap_write(ocelot->targets[target], |
|---|
| 33 | 33 | ocelot->map[target][reg & REG_MASK] + offset, val); |
|---|
| 34 | 34 | } |
|---|
| 35 | | -EXPORT_SYMBOL(__ocelot_write_ix); |
|---|
| 35 | +EXPORT_SYMBOL_GPL(__ocelot_write_ix); |
|---|
| 36 | 36 | |
|---|
| 37 | 37 | void __ocelot_rmw_ix(struct ocelot *ocelot, u32 val, u32 mask, u32 reg, |
|---|
| 38 | 38 | u32 offset) |
|---|
| .. | .. |
|---|
| 45 | 45 | ocelot->map[target][reg & REG_MASK] + offset, |
|---|
| 46 | 46 | mask, val); |
|---|
| 47 | 47 | } |
|---|
| 48 | | -EXPORT_SYMBOL(__ocelot_rmw_ix); |
|---|
| 48 | +EXPORT_SYMBOL_GPL(__ocelot_rmw_ix); |
|---|
| 49 | 49 | |
|---|
| 50 | 50 | u32 ocelot_port_readl(struct ocelot_port *port, u32 reg) |
|---|
| 51 | 51 | { |
|---|
| 52 | | - return readl(port->regs + reg); |
|---|
| 52 | + struct ocelot *ocelot = port->ocelot; |
|---|
| 53 | + u16 target = reg >> TARGET_OFFSET; |
|---|
| 54 | + u32 val; |
|---|
| 55 | + |
|---|
| 56 | + WARN_ON(!target); |
|---|
| 57 | + |
|---|
| 58 | + regmap_read(port->target, ocelot->map[target][reg & REG_MASK], &val); |
|---|
| 59 | + return val; |
|---|
| 53 | 60 | } |
|---|
| 54 | | -EXPORT_SYMBOL(ocelot_port_readl); |
|---|
| 61 | +EXPORT_SYMBOL_GPL(ocelot_port_readl); |
|---|
| 55 | 62 | |
|---|
| 56 | 63 | void ocelot_port_writel(struct ocelot_port *port, u32 val, u32 reg) |
|---|
| 57 | 64 | { |
|---|
| 58 | | - writel(val, port->regs + reg); |
|---|
| 65 | + struct ocelot *ocelot = port->ocelot; |
|---|
| 66 | + u16 target = reg >> TARGET_OFFSET; |
|---|
| 67 | + |
|---|
| 68 | + WARN_ON(!target); |
|---|
| 69 | + |
|---|
| 70 | + regmap_write(port->target, ocelot->map[target][reg & REG_MASK], val); |
|---|
| 59 | 71 | } |
|---|
| 60 | | -EXPORT_SYMBOL(ocelot_port_writel); |
|---|
| 72 | +EXPORT_SYMBOL_GPL(ocelot_port_writel); |
|---|
| 73 | + |
|---|
| 74 | +void ocelot_port_rmwl(struct ocelot_port *port, u32 val, u32 mask, u32 reg) |
|---|
| 75 | +{ |
|---|
| 76 | + u32 cur = ocelot_port_readl(port, reg); |
|---|
| 77 | + |
|---|
| 78 | + ocelot_port_writel(port, (cur & (~mask)) | val, reg); |
|---|
| 79 | +} |
|---|
| 80 | +EXPORT_SYMBOL_GPL(ocelot_port_rmwl); |
|---|
| 81 | + |
|---|
| 82 | +u32 __ocelot_target_read_ix(struct ocelot *ocelot, enum ocelot_target target, |
|---|
| 83 | + u32 reg, u32 offset) |
|---|
| 84 | +{ |
|---|
| 85 | + u32 val; |
|---|
| 86 | + |
|---|
| 87 | + regmap_read(ocelot->targets[target], |
|---|
| 88 | + ocelot->map[target][reg] + offset, &val); |
|---|
| 89 | + return val; |
|---|
| 90 | +} |
|---|
| 91 | + |
|---|
| 92 | +void __ocelot_target_write_ix(struct ocelot *ocelot, enum ocelot_target target, |
|---|
| 93 | + u32 val, u32 reg, u32 offset) |
|---|
| 94 | +{ |
|---|
| 95 | + regmap_write(ocelot->targets[target], |
|---|
| 96 | + ocelot->map[target][reg] + offset, val); |
|---|
| 97 | +} |
|---|
| 61 | 98 | |
|---|
| 62 | 99 | int ocelot_regfields_init(struct ocelot *ocelot, |
|---|
| 63 | 100 | const struct reg_field *const regfields) |
|---|
| .. | .. |
|---|
| 77 | 114 | regfield.reg = ocelot->map[target][reg & REG_MASK]; |
|---|
| 78 | 115 | regfield.lsb = regfields[i].lsb; |
|---|
| 79 | 116 | regfield.msb = regfields[i].msb; |
|---|
| 117 | + regfield.id_size = regfields[i].id_size; |
|---|
| 118 | + regfield.id_offset = regfields[i].id_offset; |
|---|
| 80 | 119 | |
|---|
| 81 | 120 | ocelot->regfields[i] = |
|---|
| 82 | 121 | devm_regmap_field_alloc(ocelot->dev, |
|---|
| .. | .. |
|---|
| 89 | 128 | |
|---|
| 90 | 129 | return 0; |
|---|
| 91 | 130 | } |
|---|
| 92 | | -EXPORT_SYMBOL(ocelot_regfields_init); |
|---|
| 131 | +EXPORT_SYMBOL_GPL(ocelot_regfields_init); |
|---|
| 93 | 132 | |
|---|
| 94 | 133 | static struct regmap_config ocelot_regmap_config = { |
|---|
| 95 | 134 | .reg_bits = 32, |
|---|
| .. | .. |
|---|
| 97 | 136 | .reg_stride = 4, |
|---|
| 98 | 137 | }; |
|---|
| 99 | 138 | |
|---|
| 100 | | -struct regmap *ocelot_io_platform_init(struct ocelot *ocelot, |
|---|
| 101 | | - struct platform_device *pdev, |
|---|
| 102 | | - const char *name) |
|---|
| 139 | +struct regmap *ocelot_regmap_init(struct ocelot *ocelot, struct resource *res) |
|---|
| 103 | 140 | { |
|---|
| 104 | | - struct resource *res; |
|---|
| 105 | 141 | void __iomem *regs; |
|---|
| 106 | 142 | |
|---|
| 107 | | - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, name); |
|---|
| 108 | 143 | regs = devm_ioremap_resource(ocelot->dev, res); |
|---|
| 109 | 144 | if (IS_ERR(regs)) |
|---|
| 110 | 145 | return ERR_CAST(regs); |
|---|
| 111 | 146 | |
|---|
| 112 | | - ocelot_regmap_config.name = name; |
|---|
| 113 | | - return devm_regmap_init_mmio(ocelot->dev, regs, |
|---|
| 114 | | - &ocelot_regmap_config); |
|---|
| 147 | + ocelot_regmap_config.name = res->name; |
|---|
| 148 | + |
|---|
| 149 | + return devm_regmap_init_mmio(ocelot->dev, regs, &ocelot_regmap_config); |
|---|
| 115 | 150 | } |
|---|
| 116 | | -EXPORT_SYMBOL(ocelot_io_platform_init); |
|---|
| 151 | +EXPORT_SYMBOL_GPL(ocelot_regmap_init); |
|---|