···11+*ST pin controller.22+33+Each multi-function pin is controlled, driven and routed through the44+PIO multiplexing block. Each pin supports GPIO functionality (ALT0)55+and multiple alternate functions(ALT1 - ALTx) that directly connect66+the pin to different hardware blocks.77+88+When a pin is in GPIO mode, Output Enable (OE), Open Drain(OD), and99+Pull Up (PU) are driven by the related PIO block.1010+1111+ST pinctrl driver controls PIO multiplexing block and also interacts with1212+gpio driver to configure a pin.1313+1414+Required properties: (PIO multiplexing block)1515+- compatible : should be "st,<SOC>-<pio-block>-pinctrl"1616+ like st,stih415-sbc-pinctrl, st,stih415-front-pinctrl and so on.1717+- gpio-controller : Indicates this device is a GPIO controller1818+- #gpio-cells : Should be one. The first cell is the pin number.1919+- st,retime-pin-mask : Should be mask to specify which pins can be retimed.2020+ If the property is not present, it is assumed that all the pins in the2121+ bank are capable of retiming. Retiming is mainly used to improve the2222+ IO timing margins of external synchronous interfaces.2323+- st,bank-name : Should be a name string for this bank as2424+ specified in datasheet.2525+- st,syscfg : Should be a phandle of the syscfg node.2626+2727+Example:2828+ pin-controller-sbc {2929+ #address-cells = <1>;3030+ #size-cells = <1>;3131+ compatible = "st,stih415-sbc-pinctrl";3232+ st,syscfg = <&syscfg_sbc>;3333+ ranges = <0 0xfe610000 0x5000>;3434+ PIO0: gpio@fe610000 {3535+ gpio-controller;3636+ #gpio-cells = <1>;3737+ reg = <0 0x100>;3838+ st,bank-name = "PIO0";3939+ };4040+ ...4141+ pin-functions nodes follow...4242+ };4343+4444+4545+Contents of function subnode node:4646+----------------------4747+Required properties for pin configuration node:4848+- st,pins : Child node with list of pins with configuration.4949+5050+Below is the format of how each pin conf should look like.5151+5252+<bank offset mux mode rt_type rt_delay rt_clk>5353+5454+Every PIO is represented with 4-7 parameters depending on retime configuration.5555+Each parameter is explained as below.5656+5757+-bank : Should be bank phandle to which this PIO belongs.5858+-offset : Offset in the PIO bank.5959+-mux : Should be alternate function number associated this pin.6060+ Use same numbers from datasheet.6161+-mode :pin configuration is selected from one of the below values.6262+ IN6363+ IN_PU6464+ OUT6565+ BIDIR6666+ BIDIR_PU6767+6868+-rt_type Retiming Configuration for the pin.6969+ Possible retime configuration are:7070+7171+ ------- -------------7272+ value args7373+ ------- -------------7474+ NICLK <delay> <clk>7575+ ICLK_IO <delay> <clk>7676+ BYPASS <delay>7777+ DE_IO <delay> <clk>7878+ SE_ICLK_IO <delay> <clk>7979+ SE_NICLK_IO <delay> <clk>8080+8181+- delay is retime delay in pico seconds as mentioned in data sheet.8282+8383+- rt_clk :clk to be use for retime.8484+ Possible values are:8585+ CLK_A8686+ CLK_B8787+ CLK_C8888+ CLK_D8989+9090+Example of mmcclk pin which is a bi-direction pull pu with retime config9191+as non inverted clock retimed with CLK_B and delay of 0 pico seconds:9292+9393+pin-controller {9494+ ...9595+ mmc0 {9696+ pinctrl_mmc: mmc {9797+ st,pins {9898+ mmcclk = <&PIO13 4 ALT4 BIDIR_PU NICLK 0 CLK_B>;9999+ ...100100+ };101101+ };102102+ ...103103+ };104104+};105105+106106+sdhci0:sdhci@fe810000{107107+ ...108108+ pinctrl-names = "default";109109+ pinctrl-0 = <&pinctrl_mmc>;110110+};
+8
drivers/base/regmap/internal.h
···176176 unsigned int window_len;177177};178178179179+struct regmap_field {180180+ struct regmap *regmap;181181+ unsigned int mask;182182+ /* lsb */183183+ unsigned int shift;184184+ unsigned int reg;185185+};186186+179187#ifdef CONFIG_DEBUG_FS180188extern void regmap_debugfs_initcall(void);181189extern void regmap_debugfs_init(struct regmap *map, const char *name);
+130
drivers/base/regmap/regmap.c
···807807}808808EXPORT_SYMBOL_GPL(devm_regmap_init);809809810810+static void regmap_field_init(struct regmap_field *rm_field,811811+ struct regmap *regmap, struct reg_field reg_field)812812+{813813+ int field_bits = reg_field.msb - reg_field.lsb + 1;814814+ rm_field->regmap = regmap;815815+ rm_field->reg = reg_field.reg;816816+ rm_field->shift = reg_field.lsb;817817+ rm_field->mask = ((BIT(field_bits) - 1) << reg_field.lsb);818818+}819819+820820+/**821821+ * devm_regmap_field_alloc(): Allocate and initialise a register field822822+ * in a register map.823823+ *824824+ * @dev: Device that will be interacted with825825+ * @regmap: regmap bank in which this register field is located.826826+ * @reg_field: Register field with in the bank.827827+ *828828+ * The return value will be an ERR_PTR() on error or a valid pointer829829+ * to a struct regmap_field. The regmap_field will be automatically freed830830+ * by the device management code.831831+ */832832+struct regmap_field *devm_regmap_field_alloc(struct device *dev,833833+ struct regmap *regmap, struct reg_field reg_field)834834+{835835+ struct regmap_field *rm_field = devm_kzalloc(dev,836836+ sizeof(*rm_field), GFP_KERNEL);837837+ if (!rm_field)838838+ return ERR_PTR(-ENOMEM);839839+840840+ regmap_field_init(rm_field, regmap, reg_field);841841+842842+ return rm_field;843843+844844+}845845+EXPORT_SYMBOL_GPL(devm_regmap_field_alloc);846846+847847+/**848848+ * devm_regmap_field_free(): Free register field allocated using849849+ * devm_regmap_field_alloc. Usally drivers need not call this function,850850+ * as the memory allocated via devm will be freed as per device-driver851851+ * life-cyle.852852+ *853853+ * @dev: Device that will be interacted with854854+ * @field: regmap field which should be freed.855855+ */856856+void devm_regmap_field_free(struct device *dev,857857+ struct regmap_field *field)858858+{859859+ devm_kfree(dev, field);860860+}861861+EXPORT_SYMBOL_GPL(devm_regmap_field_free);862862+863863+/**864864+ * regmap_field_alloc(): Allocate and initialise a register field865865+ * in a register map.866866+ *867867+ * @regmap: regmap bank in which this register field is located.868868+ * @reg_field: Register field with in the bank.869869+ *870870+ * The return value will be an ERR_PTR() on error or a valid pointer871871+ * to a struct regmap_field. The regmap_field should be freed by the872872+ * user once its finished working with it using regmap_field_free().873873+ */874874+struct regmap_field *regmap_field_alloc(struct regmap *regmap,875875+ struct reg_field reg_field)876876+{877877+ struct regmap_field *rm_field = kzalloc(sizeof(*rm_field), GFP_KERNEL);878878+879879+ if (!rm_field)880880+ return ERR_PTR(-ENOMEM);881881+882882+ regmap_field_init(rm_field, regmap, reg_field);883883+884884+ return rm_field;885885+}886886+EXPORT_SYMBOL_GPL(regmap_field_alloc);887887+888888+/**889889+ * regmap_field_free(): Free register field allocated using regmap_field_alloc890890+ *891891+ * @field: regmap field which should be freed.892892+ */893893+void regmap_field_free(struct regmap_field *field)894894+{895895+ kfree(field);896896+}897897+EXPORT_SYMBOL_GPL(regmap_field_free);898898+810899/**811900 * regmap_reinit_cache(): Reinitialise the current register cache812901 *···13441255}13451256EXPORT_SYMBOL_GPL(regmap_raw_write);1346125712581258+/**12591259+ * regmap_field_write(): Write a value to a single register field12601260+ *12611261+ * @field: Register field to write to12621262+ * @val: Value to be written12631263+ *12641264+ * A value of zero will be returned on success, a negative errno will12651265+ * be returned in error cases.12661266+ */12671267+int regmap_field_write(struct regmap_field *field, unsigned int val)12681268+{12691269+ return regmap_update_bits(field->regmap, field->reg,12701270+ field->mask, val << field->shift);12711271+}12721272+EXPORT_SYMBOL_GPL(regmap_field_write);12731273+13471274/*13481275 * regmap_bulk_write(): Write multiple registers to the device13491276 *···16411536 return ret;16421537}16431538EXPORT_SYMBOL_GPL(regmap_raw_read);15391539+15401540+/**15411541+ * regmap_field_read(): Read a value to a single register field15421542+ *15431543+ * @field: Register field to read from15441544+ * @val: Pointer to store read value15451545+ *15461546+ * A value of zero will be returned on success, a negative errno will15471547+ * be returned in error cases.15481548+ */15491549+int regmap_field_read(struct regmap_field *field, unsigned int *val)15501550+{15511551+ int ret;15521552+ unsigned int reg_val;15531553+ ret = regmap_read(field->regmap, field->reg, ®_val);15541554+ if (ret != 0)15551555+ return ret;15561556+15571557+ reg_val &= field->mask;15581558+ reg_val >>= field->shift;15591559+ *val = reg_val;15601560+15611561+ return ret;15621562+}15631563+EXPORT_SYMBOL_GPL(regmap_field_read);1644156416451565/**16461566 * regmap_bulk_read(): Read multiple registers from the device