Lines Matching refs:p
30 static u8 bq4802_read_io(struct bq4802 *p, int off) in bq4802_read_io() argument
32 return inb(p->ioport + off); in bq4802_read_io()
35 static void bq4802_write_io(struct bq4802 *p, int off, u8 val) in bq4802_write_io() argument
37 outb(val, p->ioport + off); in bq4802_write_io()
40 static u8 bq4802_read_mem(struct bq4802 *p, int off) in bq4802_read_mem() argument
42 return readb(p->regs + off); in bq4802_read_mem()
45 static void bq4802_write_mem(struct bq4802 *p, int off, u8 val) in bq4802_write_mem() argument
47 writeb(val, p->regs + off); in bq4802_write_mem()
52 struct bq4802 *p = dev_get_drvdata(dev); in bq4802_read_time() local
57 spin_lock_irqsave(&p->lock, flags); in bq4802_read_time()
59 val = p->read(p, 0x0e); in bq4802_read_time()
60 p->write(p, 0xe, val | 0x08); in bq4802_read_time()
62 tm->tm_sec = p->read(p, 0x00); in bq4802_read_time()
63 tm->tm_min = p->read(p, 0x02); in bq4802_read_time()
64 tm->tm_hour = p->read(p, 0x04); in bq4802_read_time()
65 tm->tm_mday = p->read(p, 0x06); in bq4802_read_time()
66 tm->tm_mon = p->read(p, 0x09); in bq4802_read_time()
67 tm->tm_year = p->read(p, 0x0a); in bq4802_read_time()
68 tm->tm_wday = p->read(p, 0x08); in bq4802_read_time()
69 century = p->read(p, 0x0f); in bq4802_read_time()
71 p->write(p, 0x0e, val); in bq4802_read_time()
73 spin_unlock_irqrestore(&p->lock, flags); in bq4802_read_time()
94 struct bq4802 *p = dev_get_drvdata(dev); in bq4802_set_time() local
117 spin_lock_irqsave(&p->lock, flags); in bq4802_set_time()
119 val = p->read(p, 0x0e); in bq4802_set_time()
120 p->write(p, 0x0e, val | 0x08); in bq4802_set_time()
122 p->write(p, 0x00, sec); in bq4802_set_time()
123 p->write(p, 0x02, min); in bq4802_set_time()
124 p->write(p, 0x04, hrs); in bq4802_set_time()
125 p->write(p, 0x06, day); in bq4802_set_time()
126 p->write(p, 0x09, mon); in bq4802_set_time()
127 p->write(p, 0x0a, yrs); in bq4802_set_time()
128 p->write(p, 0x0f, century); in bq4802_set_time()
130 p->write(p, 0x0e, val); in bq4802_set_time()
132 spin_unlock_irqrestore(&p->lock, flags); in bq4802_set_time()
144 struct bq4802 *p = devm_kzalloc(&pdev->dev, sizeof(*p), GFP_KERNEL); in bq4802_probe() local
147 if (!p) in bq4802_probe()
150 spin_lock_init(&p->lock); in bq4802_probe()
152 p->r = platform_get_resource(pdev, IORESOURCE_MEM, 0); in bq4802_probe()
153 if (!p->r) { in bq4802_probe()
154 p->r = platform_get_resource(pdev, IORESOURCE_IO, 0); in bq4802_probe()
156 if (!p->r) in bq4802_probe()
159 if (p->r->flags & IORESOURCE_IO) { in bq4802_probe()
160 p->ioport = p->r->start; in bq4802_probe()
161 p->read = bq4802_read_io; in bq4802_probe()
162 p->write = bq4802_write_io; in bq4802_probe()
163 } else if (p->r->flags & IORESOURCE_MEM) { in bq4802_probe()
164 p->regs = devm_ioremap(&pdev->dev, p->r->start, in bq4802_probe()
165 resource_size(p->r)); in bq4802_probe()
166 if (!p->regs){ in bq4802_probe()
170 p->read = bq4802_read_mem; in bq4802_probe()
171 p->write = bq4802_write_mem; in bq4802_probe()
177 platform_set_drvdata(pdev, p); in bq4802_probe()
179 p->rtc = devm_rtc_device_register(&pdev->dev, "bq4802", in bq4802_probe()
181 if (IS_ERR(p->rtc)) { in bq4802_probe()
182 err = PTR_ERR(p->rtc); in bq4802_probe()