From 8f34efaaf8d49fb4cc87c1c62ce3bc7e56b0b0c3 Mon Sep 17 00:00:00 2001 From: jmcneill Date: Mon, 28 Mar 2016 11:51:35 +0000 Subject: [PATCH] Pass clkdev_if methods through to parent device by default. Reviewed by: mmel, adrian (mentor) Approved by: adrian (mentor) Differential Revision: https://reviews.freebsd.org/D5750 --- sys/dev/extres/clk/clkdev_if.m | 58 +++++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 5 deletions(-) diff --git a/sys/dev/extres/clk/clkdev_if.m b/sys/dev/extres/clk/clkdev_if.m index 710ee4640d89..f9f5084d2c77 100644 --- a/sys/dev/extres/clk/clkdev_if.m +++ b/sys/dev/extres/clk/clkdev_if.m @@ -32,18 +32,66 @@ INTERFACE clkdev; CODE { #include + #include + static int + clkdev_default_write_4(device_t dev, bus_addr_t addr, uint32_t val) + { + device_t pdev; + + pdev = device_get_parent(dev); + if (pdev == NULL) + return (ENXIO); + + return (CLKDEV_WRITE_4(pdev, addr, val)); + } + + static int + clkdev_default_read_4(device_t dev, bus_addr_t addr, uint32_t *val) + { + device_t pdev; + + pdev = device_get_parent(dev); + if (pdev == NULL) + return (ENXIO); + + return (CLKDEV_READ_4(pdev, addr, val)); + } + + static int + clkdev_default_modify_4(device_t dev, bus_addr_t addr, + uint32_t clear_mask, uint32_t set_mask) + { + device_t pdev; + + pdev = device_get_parent(dev); + if (pdev == NULL) + return (ENXIO); + + return (CLKDEV_MODIFY_4(pdev, addr, clear_mask, set_mask)); + } + static void clkdev_default_device_lock(device_t dev) { + device_t pdev; - panic("clkdev_device_lock() is not implemented"); + pdev = device_get_parent(dev); + if (pdev == NULL) + panic("clkdev_device_lock not implemented"); + + CLKDEV_DEVICE_LOCK(pdev); } static void clkdev_default_device_unlock(device_t dev) { + device_t pdev; - panic("clkdev_device_unlock() is not implemented"); + pdev = device_get_parent(dev); + if (pdev == NULL) + panic("clkdev_device_unlock not implemented"); + + CLKDEV_DEVICE_UNLOCK(pdev); } } @@ -54,7 +102,7 @@ METHOD int write_4 { device_t dev; bus_addr_t addr; uint32_t val; -}; +} DEFAULT clkdev_default_write_4; # # Read single register @@ -63,7 +111,7 @@ METHOD int read_4 { device_t dev; bus_addr_t addr; uint32_t *val; -}; +} DEFAULT clkdev_default_read_4; # # Modify single register @@ -73,7 +121,7 @@ METHOD int modify_4 { bus_addr_t addr; uint32_t clear_mask; uint32_t set_mask; -}; +} DEFAULT clkdev_default_modify_4; # # Get exclusive access to underlying device