23 #include <linux/module.h>
25 #include <linux/rtc.h>
26 #include <linux/types.h>
31 #include <linux/slab.h>
88 static void v3020_mmio_unmap(
struct v3020 *
chip)
93 static void v3020_mmio_write_bit(
struct v3020 *
chip,
unsigned char bit)
98 static unsigned char v3020_mmio_read_bit(
struct v3020 *
chip)
104 .map_io = v3020_mmio_map,
105 .unmap_io = v3020_mmio_unmap,
106 .read_bit = v3020_mmio_read_bit,
107 .write_bit = v3020_mmio_write_bit,
127 for (i = 0; i <
ARRAY_SIZE(v3020_gpio); i++) {
135 chip->
gpio = v3020_gpio;
146 static void v3020_gpio_unmap(
struct v3020 *chip)
154 static void v3020_gpio_write_bit(
struct v3020 *chip,
unsigned char bit)
164 static unsigned char v3020_gpio_read_bit(
struct v3020 *chip)
181 .map_io = v3020_gpio_map,
182 .unmap_io = v3020_gpio_unmap,
183 .read_bit = v3020_gpio_read_bit,
184 .write_bit = v3020_gpio_write_bit,
187 static void v3020_set_reg(
struct v3020 *chip,
unsigned char address,
194 for (i = 0; i < 4; i++) {
195 chip->
ops->write_bit(chip, (tmp & 1));
202 for (i = 0; i < 8; i++) {
203 chip->
ops->write_bit(chip, (data & 1));
210 static unsigned char v3020_get_reg(
struct v3020 *chip,
unsigned char address)
212 unsigned int data = 0;
215 for (i = 0; i < 4; i++) {
216 chip->
ops->write_bit(chip, (address & 1));
221 for (i = 0; i < 8; i++) {
223 if (chip->
ops->read_bit(chip))
255 dev_dbg(dev,
"\n%s : Read RTC values\n", __func__);
272 dev_dbg(dev,
"\n%s : Setting RTC values\n", __func__);
300 .read_time = v3020_read_time,
301 .set_time = v3020_set_time,
317 chip->
ops = &v3020_gpio_ops;
319 chip->
ops = &v3020_mmio_ops;
321 retval = chip->
ops->map_io(chip, pdev, pdata);
327 for (i = 0; i < 8; i++)
328 temp = chip->
ops->read_bit(chip);
349 "physical address 0x%llx,"
350 "data connected to D%d\n",
351 (
unsigned long long)pdev->
resource[0].start,
354 platform_set_drvdata(pdev, chip);
358 if (IS_ERR(chip->
rtc)) {
359 retval = PTR_ERR(chip->
rtc);
366 chip->
ops->unmap_io(chip);
375 struct v3020 *chip = platform_get_drvdata(dev);
381 chip->
ops->unmap_io(chip);
389 .remove = rtc_remove,