Add method for getting of syscon handle from parent device.
If simple multifuction device also provides syscon interface, its childern should be able to consume it. Due to this: - declare coresponding method in syscon interface - implement it in simple multifunction device driver MFC after: 1 week
This commit is contained in:
parent
3921068f1e
commit
7f8c4c78f5
@ -254,3 +254,14 @@ syscon_get_by_ofw_property(device_t cdev, phandle_t cnode, char *name,
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
syscon_get_handle_default(device_t dev, struct syscon **syscon)
|
||||
{
|
||||
device_t parent;
|
||||
|
||||
parent = device_get_parent(dev);
|
||||
if (parent == NULL)
|
||||
return (ENODEV);
|
||||
return (SYSCON_GET_HANDLE(parent, syscon));
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ INTERFACE syscon;
|
||||
|
||||
HEADER {
|
||||
struct syscon;
|
||||
int syscon_get_handle_default(device_t dev, struct syscon **syscon);
|
||||
}
|
||||
|
||||
METHOD int init {
|
||||
@ -62,3 +63,11 @@ METHOD int modify_4 {
|
||||
uint32_t clear_bits;
|
||||
uint32_t set_bits;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get syscon handle from parent driver
|
||||
*/
|
||||
METHOD int get_handle {
|
||||
device_t dev;
|
||||
struct syscon **syscon;
|
||||
} DEFAULT syscon_get_handle_default;
|
||||
|
@ -49,14 +49,16 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
device_t simple_mfd_add_device(device_t dev, phandle_t node, u_int order,
|
||||
const char *name, int unit, struct simplebus_devinfo *di);
|
||||
struct simplebus_devinfo *simple_mfd_setup_dinfo(device_t dev, phandle_t node, struct simplebus_devinfo *di);
|
||||
struct simplebus_devinfo *simple_mfd_setup_dinfo(device_t dev, phandle_t node,
|
||||
struct simplebus_devinfo *di);
|
||||
|
||||
#include "syscon_if.h"
|
||||
#include <dev/extres/syscon/syscon.h>
|
||||
|
||||
MALLOC_DECLARE(M_SYSCON);
|
||||
|
||||
static uint32_t simple_mfd_syscon_read_4(struct syscon *syscon, bus_size_t offset);
|
||||
static uint32_t simple_mfd_syscon_read_4(struct syscon *syscon,
|
||||
bus_size_t offset);
|
||||
static int simple_mfd_syscon_write_4(struct syscon *syscon, bus_size_t offset,
|
||||
uint32_t val);
|
||||
static int simple_mfd_syscon_modify_4(struct syscon *syscon, bus_size_t offset,
|
||||
@ -125,6 +127,17 @@ simple_mfd_syscon_modify_4(struct syscon *syscon, bus_size_t offset,
|
||||
SYSCON_UNLOCK(sc);
|
||||
return (0);
|
||||
}
|
||||
static int
|
||||
simple_mfd_syscon_get_handle(device_t dev, struct syscon **syscon)
|
||||
{
|
||||
struct simple_mfd_softc *sc;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
*syscon = sc->syscon;
|
||||
if (syscon == NULL)
|
||||
return (ENODEV);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
simple_mfd_probe(device_t dev)
|
||||
@ -278,6 +291,8 @@ simple_mfd_add_device(device_t dev, phandle_t node, u_int order,
|
||||
}
|
||||
|
||||
static device_method_t simple_mfd_methods[] = {
|
||||
/* syscon interface */
|
||||
DEVMETHOD(syscon_get_handle, simple_mfd_syscon_get_handle),
|
||||
/* Device interface */
|
||||
DEVMETHOD(device_probe, simple_mfd_probe),
|
||||
DEVMETHOD(device_attach, simple_mfd_attach),
|
||||
|
Loading…
Reference in New Issue
Block a user