Lines Matching refs:eeprom
54 static inline void lpc18xx_eeprom_writel(struct lpc18xx_eeprom_dev *eeprom, in lpc18xx_eeprom_writel() argument
57 writel(val, eeprom->reg_base + reg); in lpc18xx_eeprom_writel()
60 static inline u32 lpc18xx_eeprom_readl(struct lpc18xx_eeprom_dev *eeprom, in lpc18xx_eeprom_readl() argument
63 return readl(eeprom->reg_base + reg); in lpc18xx_eeprom_readl()
66 static int lpc18xx_eeprom_busywait_until_prog(struct lpc18xx_eeprom_dev *eeprom) in lpc18xx_eeprom_busywait_until_prog() argument
75 val = lpc18xx_eeprom_readl(eeprom, LPC18XX_EEPROM_INTSTAT); in lpc18xx_eeprom_busywait_until_prog()
78 lpc18xx_eeprom_writel(eeprom, LPC18XX_EEPROM_INTSTATCLR, in lpc18xx_eeprom_busywait_until_prog()
93 struct lpc18xx_eeprom_dev *eeprom = context; in lpc18xx_eeprom_gather_write() local
101 if ((reg > eeprom->size - LPC18XX_EEPROM_PAGE_SIZE) || in lpc18xx_eeprom_gather_write()
102 (reg + bytes > eeprom->size - LPC18XX_EEPROM_PAGE_SIZE)) in lpc18xx_eeprom_gather_write()
106 lpc18xx_eeprom_writel(eeprom, LPC18XX_EEPROM_PWRDWN, in lpc18xx_eeprom_gather_write()
113 writel(*(u32 *)val, eeprom->mem_base + offset); in lpc18xx_eeprom_gather_write()
114 ret = lpc18xx_eeprom_busywait_until_prog(eeprom); in lpc18xx_eeprom_gather_write()
118 bytes -= eeprom->val_bytes; in lpc18xx_eeprom_gather_write()
119 val += eeprom->val_bytes; in lpc18xx_eeprom_gather_write()
120 offset += eeprom->val_bytes; in lpc18xx_eeprom_gather_write()
123 lpc18xx_eeprom_writel(eeprom, LPC18XX_EEPROM_PWRDWN, in lpc18xx_eeprom_gather_write()
132 struct lpc18xx_eeprom_dev *eeprom = context; in lpc18xx_eeprom_read() local
134 lpc18xx_eeprom_writel(eeprom, LPC18XX_EEPROM_PWRDWN, in lpc18xx_eeprom_read()
141 *(u32 *)val = readl(eeprom->mem_base + offset); in lpc18xx_eeprom_read()
142 bytes -= eeprom->val_bytes; in lpc18xx_eeprom_read()
143 val += eeprom->val_bytes; in lpc18xx_eeprom_read()
144 offset += eeprom->val_bytes; in lpc18xx_eeprom_read()
147 lpc18xx_eeprom_writel(eeprom, LPC18XX_EEPROM_PWRDWN, in lpc18xx_eeprom_read()
164 struct lpc18xx_eeprom_dev *eeprom; in lpc18xx_eeprom_probe() local
171 eeprom = devm_kzalloc(dev, sizeof(*eeprom), GFP_KERNEL); in lpc18xx_eeprom_probe()
172 if (!eeprom) in lpc18xx_eeprom_probe()
176 eeprom->reg_base = devm_ioremap_resource(dev, res); in lpc18xx_eeprom_probe()
177 if (IS_ERR(eeprom->reg_base)) in lpc18xx_eeprom_probe()
178 return PTR_ERR(eeprom->reg_base); in lpc18xx_eeprom_probe()
181 eeprom->mem_base = devm_ioremap_resource(dev, res); in lpc18xx_eeprom_probe()
182 if (IS_ERR(eeprom->mem_base)) in lpc18xx_eeprom_probe()
183 return PTR_ERR(eeprom->mem_base); in lpc18xx_eeprom_probe()
185 eeprom->clk = devm_clk_get(&pdev->dev, "eeprom"); in lpc18xx_eeprom_probe()
186 if (IS_ERR(eeprom->clk)) { in lpc18xx_eeprom_probe()
188 return PTR_ERR(eeprom->clk); in lpc18xx_eeprom_probe()
191 ret = clk_prepare_enable(eeprom->clk); in lpc18xx_eeprom_probe()
210 eeprom->val_bytes = 4; in lpc18xx_eeprom_probe()
211 eeprom->reg_bytes = 4; in lpc18xx_eeprom_probe()
217 clk_rate = clk_get_rate(eeprom->clk); in lpc18xx_eeprom_probe()
219 lpc18xx_eeprom_writel(eeprom, LPC18XX_EEPROM_CLKDIV, clk_rate); in lpc18xx_eeprom_probe()
225 lpc18xx_eeprom_writel(eeprom, LPC18XX_EEPROM_AUTOPROG, in lpc18xx_eeprom_probe()
228 lpc18xx_eeprom_writel(eeprom, LPC18XX_EEPROM_PWRDWN, in lpc18xx_eeprom_probe()
231 eeprom->size = resource_size(res); in lpc18xx_eeprom_probe()
234 lpc18xx_nvmem_config.priv = eeprom; in lpc18xx_eeprom_probe()
236 eeprom->nvmem = devm_nvmem_register(dev, &lpc18xx_nvmem_config); in lpc18xx_eeprom_probe()
237 if (IS_ERR(eeprom->nvmem)) { in lpc18xx_eeprom_probe()
238 ret = PTR_ERR(eeprom->nvmem); in lpc18xx_eeprom_probe()
242 platform_set_drvdata(pdev, eeprom); in lpc18xx_eeprom_probe()
247 clk_disable_unprepare(eeprom->clk); in lpc18xx_eeprom_probe()
254 struct lpc18xx_eeprom_dev *eeprom = platform_get_drvdata(pdev); in lpc18xx_eeprom_remove() local
256 clk_disable_unprepare(eeprom->clk); in lpc18xx_eeprom_remove()