Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/iicbus/rtc/hym8563.c
| Show All 34 Lines | |||||
| #include <sys/param.h> | #include <sys/param.h> | ||||
| #include <sys/systm.h> | #include <sys/systm.h> | ||||
| #include <sys/bus.h> | #include <sys/bus.h> | ||||
| #include <sys/clock.h> | #include <sys/clock.h> | ||||
| #include <sys/kernel.h> | #include <sys/kernel.h> | ||||
| #include <sys/lock.h> | #include <sys/lock.h> | ||||
| #include <sys/module.h> | #include <sys/module.h> | ||||
| #if defined(FDT) && !defined(__powerpc64__) | #if defined(FDT) | ||||
| #if !defined(__powerpc__) | |||||
| #include <dev/clk/clk.h> | #include <dev/clk/clk.h> | ||||
| #endif | |||||
| #include <dev/ofw/ofw_bus.h> | #include <dev/ofw/ofw_bus.h> | ||||
| #include <dev/ofw/ofw_bus_subr.h> | #include <dev/ofw/ofw_bus_subr.h> | ||||
| #endif | #endif | ||||
| #include <dev/iicbus/iiconf.h> | #include <dev/iicbus/iiconf.h> | ||||
| #include <dev/iicbus/iicbus.h> | #include <dev/iicbus/iicbus.h> | ||||
| #include "clock_if.h" | #include "clock_if.h" | ||||
| Show All 31 Lines | |||||
| #define HYM8563_CLKOUT_1 3 | #define HYM8563_CLKOUT_1 3 | ||||
| #define HYM8563_CLKOUT_MASK 3 | #define HYM8563_CLKOUT_MASK 3 | ||||
| struct hym8563_softc { | struct hym8563_softc { | ||||
| device_t dev; | device_t dev; | ||||
| struct intr_config_hook init_hook; | struct intr_config_hook init_hook; | ||||
| }; | }; | ||||
| #if defined(FDT) && !defined(__powerpc64__) | #if defined(FDT) | ||||
| #if !defined(__powerpc__) | |||||
| /* Clock class and method */ | /* Clock class and method */ | ||||
| struct hym8563_clk_sc { | struct hym8563_clk_sc { | ||||
| device_t base_dev; | device_t base_dev; | ||||
| }; | }; | ||||
| #endif | |||||
| static struct ofw_compat_data compat_data[] = { | static struct ofw_compat_data compat_data[] = { | ||||
| {"haoyu,hym8563", 1}, | {"haoyu,hym8563", 1}, | ||||
| {NULL, 0}, | {NULL, 0}, | ||||
| }; | }; | ||||
| #endif | #endif | ||||
| Show All 21 Lines | |||||
| static inline int | static inline int | ||||
| hym8563_write_1(device_t dev, uint8_t reg, uint8_t val) | hym8563_write_1(device_t dev, uint8_t reg, uint8_t val) | ||||
| { | { | ||||
| return (iicdev_writeto(dev, reg, &val, 1, IIC_WAIT)); | return (iicdev_writeto(dev, reg, &val, 1, IIC_WAIT)); | ||||
| } | } | ||||
| #if defined(FDT) && !defined(__powerpc64__) | #if defined(FDT) && !defined(__powerpc__) | ||||
| static int | static int | ||||
| hym8563_clk_set_gate(struct clknode *clk, bool enable) | hym8563_clk_set_gate(struct clknode *clk, bool enable) | ||||
| { | { | ||||
| struct hym8563_clk_sc *sc; | struct hym8563_clk_sc *sc; | ||||
| uint8_t val; | uint8_t val; | ||||
| int rv; | int rv; | ||||
| sc = clknode_get_softc(clk); | sc = clknode_get_softc(clk); | ||||
| ▲ Show 20 Lines • Show All 282 Lines • ▼ Show 20 Lines | hym8563_init(void *arg) | ||||
| clock_schedule(sc->dev, 1); | clock_schedule(sc->dev, 1); | ||||
| return; | return; | ||||
| } | } | ||||
| static int | static int | ||||
| hym8563_probe(device_t dev) | hym8563_probe(device_t dev) | ||||
| { | { | ||||
| #if defined(FDT) && !defined(__powerpc64__) | #if defined(FDT) | ||||
| if (!ofw_bus_status_okay(dev)) | if (!ofw_bus_status_okay(dev)) | ||||
| return (ENXIO); | return (ENXIO); | ||||
| if (ofw_bus_search_compatible(dev, compat_data)->ocd_data != 0) { | if (ofw_bus_search_compatible(dev, compat_data)->ocd_data != 0) { | ||||
| device_set_desc(dev, "HYM8694 RTC"); | device_set_desc(dev, "HYM8694 RTC"); | ||||
| return (BUS_PROBE_DEFAULT); | return (BUS_PROBE_DEFAULT); | ||||
| } | } | ||||
| #endif | #endif | ||||
| return (ENXIO); | return (ENXIO); | ||||
| } | } | ||||
| static int | static int | ||||
| hym8563_attach(device_t dev) | hym8563_attach(device_t dev) | ||||
| { | { | ||||
| struct hym8563_softc *sc; | struct hym8563_softc *sc; | ||||
| sc = device_get_softc(dev); | sc = device_get_softc(dev); | ||||
| sc->dev = dev; | sc->dev = dev; | ||||
| #if defined(FDT) && !defined(__powerpc64__) | #if defined(FDT) && !defined(__powerpc__) | ||||
| if (hym8563_attach_clocks(sc) != 0) | if (hym8563_attach_clocks(sc) != 0) | ||||
| return(ENXIO); | return(ENXIO); | ||||
| #endif | #endif | ||||
| /* | /* | ||||
| * Chip init must wait until interrupts are enabled. Often i2c access | * Chip init must wait until interrupts are enabled. Often i2c access | ||||
| * works only when the interrupts are available. | * works only when the interrupts are available. | ||||
| */ | */ | ||||
| Show All 27 Lines | |||||
| }; | }; | ||||
| static DEFINE_CLASS_0(hym8563_rtc, hym8563_driver, hym8563_methods, | static DEFINE_CLASS_0(hym8563_rtc, hym8563_driver, hym8563_methods, | ||||
| sizeof(struct hym8563_softc)); | sizeof(struct hym8563_softc)); | ||||
| EARLY_DRIVER_MODULE(hym8563, iicbus, hym8563_driver, NULL, NULL, | EARLY_DRIVER_MODULE(hym8563, iicbus, hym8563_driver, NULL, NULL, | ||||
| BUS_PASS_SUPPORTDEV + BUS_PASS_ORDER_FIRST); | BUS_PASS_SUPPORTDEV + BUS_PASS_ORDER_FIRST); | ||||
| MODULE_VERSION(hym8563, 1); | MODULE_VERSION(hym8563, 1); | ||||
| MODULE_DEPEND(hym8563, iicbus, IICBUS_MINVER, IICBUS_PREFVER, IICBUS_MAXVER); | MODULE_DEPEND(hym8563, iicbus, IICBUS_MINVER, IICBUS_PREFVER, IICBUS_MAXVER); | ||||
| #if defined(FDT) && !defined(__powerpc64__) | #if defined(FDT) | ||||
| IICBUS_FDT_PNP_INFO(compat_data); | IICBUS_FDT_PNP_INFO(compat_data); | ||||
| #endif | #endif | ||||
| No newline at end of file | |||||