Lines Matching refs:ds1wm_data
87 struct ds1wm_data {
102 static inline void ds1wm_write_register(struct ds1wm_data *ds1wm_data, u32 reg,
105 __raw_writeb(val, ds1wm_data->map + (reg << ds1wm_data->bus_shift));
108 static inline u8 ds1wm_read_register(struct ds1wm_data *ds1wm_data, u32 reg)
110 return __raw_readb(ds1wm_data->map + (reg << ds1wm_data->bus_shift));
116 struct ds1wm_data *ds1wm_data = data;
117 u8 intr = ds1wm_read_register(ds1wm_data, DS1WM_INT);
119 ds1wm_data->slave_present = (intr & DS1WM_INT_PDR) ? 0 : 1;
121 if ((intr & DS1WM_INT_PD) && ds1wm_data->reset_complete)
122 complete(ds1wm_data->reset_complete);
124 if ((intr & DS1WM_INT_TSRE) && ds1wm_data->write_complete)
125 complete(ds1wm_data->write_complete);
128 ds1wm_data->read_byte = ds1wm_read_register(ds1wm_data,
130 if (ds1wm_data->read_complete)
131 complete(ds1wm_data->read_complete);
137 static int ds1wm_reset(struct ds1wm_data *ds1wm_data)
142 ds1wm_data->reset_complete = &reset_done;
144 ds1wm_write_register(ds1wm_data, DS1WM_INT_EN, DS1WM_INTEN_EPD |
145 (ds1wm_data->active_high ? DS1WM_INTEN_IAS : 0));
147 ds1wm_write_register(ds1wm_data, DS1WM_CMD, DS1WM_CMD_1W_RESET);
150 ds1wm_data->reset_complete = NULL;
152 dev_dbg(&ds1wm_data->pdev->dev, "reset failed\n");
165 ds1wm_write_register(ds1wm_data, DS1WM_INT_EN,
167 (ds1wm_data->active_high ? DS1WM_INTEN_IAS : 0));
169 if (!ds1wm_data->slave_present) {
170 dev_dbg(&ds1wm_data->pdev->dev, "reset: no devices found\n");
177 static int ds1wm_write(struct ds1wm_data *ds1wm_data, u8 data)
180 ds1wm_data->write_complete = &write_done;
182 ds1wm_write_register(ds1wm_data, DS1WM_DATA, data);
185 ds1wm_data->write_complete = NULL;
190 static int ds1wm_read(struct ds1wm_data *ds1wm_data, unsigned char write_data)
193 ds1wm_data->read_complete = &read_done;
195 ds1wm_write(ds1wm_data, write_data);
197 ds1wm_data->read_complete = NULL;
199 return ds1wm_data->read_byte;
213 static void ds1wm_up(struct ds1wm_data *ds1wm_data)
217 if (ds1wm_data->pdata->enable)
218 ds1wm_data->pdata->enable(ds1wm_data->pdev);
220 gclk = clk_get_rate(ds1wm_data->clk);
221 clk_enable(ds1wm_data->clk);
224 dev_err(&ds1wm_data->pdev->dev,
228 ds1wm_write_register(ds1wm_data, DS1WM_CLKDIV, divisor);
233 ds1wm_reset(ds1wm_data);
236 static void ds1wm_down(struct ds1wm_data *ds1wm_data)
238 ds1wm_reset(ds1wm_data);
241 ds1wm_write_register(ds1wm_data, DS1WM_INT_EN,
242 ds1wm_data->active_high ? DS1WM_INTEN_IAS : 0);
244 if (ds1wm_data->pdata->disable)
245 ds1wm_data->pdata->disable(ds1wm_data->pdev);
247 clk_disable(ds1wm_data->clk);
255 struct ds1wm_data *ds1wm_data = data;
257 return ds1wm_read(ds1wm_data, 0xff);
262 struct ds1wm_data *ds1wm_data = data;
264 ds1wm_write(ds1wm_data, byte);
269 struct ds1wm_data *ds1wm_data = data;
271 ds1wm_reset(ds1wm_data);
279 struct ds1wm_data *ds1wm_data = data;
283 if (ds1wm_reset(ds1wm_data))
286 ds1wm_write(ds1wm_data, search_type);
287 ds1wm_write_register(ds1wm_data, DS1WM_CMD, DS1WM_CMD_SRA);
293 resp = ds1wm_read(ds1wm_data, 0x00);
308 dev_dbg(&ds1wm_data->pdev->dev, "found 0x%08llX", rom_id);
310 ds1wm_write_register(ds1wm_data, DS1WM_CMD, ~DS1WM_CMD_SRA);
311 ds1wm_reset(ds1wm_data);
313 slave_found(ds1wm_data, rom_id);
327 struct ds1wm_data *ds1wm_data;
335 ds1wm_data = kzalloc(sizeof (*ds1wm_data), GFP_KERNEL);
336 if (!ds1wm_data)
339 platform_set_drvdata(pdev, ds1wm_data);
346 ds1wm_data->map = ioremap(res->start, res->end - res->start + 1);
347 if (!ds1wm_data->map) {
352 ds1wm_data->bus_shift = plat->bus_shift;
353 ds1wm_data->pdev = pdev;
354 ds1wm_data->pdata = plat;
361 ds1wm_data->irq = res->start;
362 ds1wm_data->active_high = (res->flags & IORESOURCE_IRQ_HIGHEDGE) ?
365 set_irq_type(ds1wm_data->irq, ds1wm_data->active_high ?
368 ret = request_irq(ds1wm_data->irq, ds1wm_isr, IRQF_DISABLED,
369 "ds1wm", ds1wm_data);
373 ds1wm_data->clk = clk_get(&pdev->dev, "ds1wm");
374 if (!ds1wm_data->clk) {
379 ds1wm_up(ds1wm_data);
381 ds1wm_master.data = (void *)ds1wm_data;
390 ds1wm_down(ds1wm_data);
391 clk_put(ds1wm_data->clk);
393 free_irq(ds1wm_data->irq, ds1wm_data);
395 iounmap(ds1wm_data->map);
397 kfree(ds1wm_data);
405 struct ds1wm_data *ds1wm_data = platform_get_drvdata(pdev);
407 ds1wm_down(ds1wm_data);
414 struct ds1wm_data *ds1wm_data = platform_get_drvdata(pdev);
416 ds1wm_up(ds1wm_data);
427 struct ds1wm_data *ds1wm_data = platform_get_drvdata(pdev);
430 ds1wm_down(ds1wm_data);
431 clk_put(ds1wm_data->clk);
432 free_irq(ds1wm_data->irq, ds1wm_data);
433 iounmap(ds1wm_data->map);
434 kfree(ds1wm_data);