Author: ian
Date: Sun Oct 26 02:19:03 2014
New Revision: 273657
URL: https://svnweb.freebsd.org/changeset/base/273657

Log:
  MFC r270957, r270959:
  
    Create an interface for drivers to enable or disable their clocks as listed
    in the clocks=<...> properties of their FDT data.

Added:
  stable/10/sys/dev/fdt/fdt_clock.c
     - copied, changed from r270957, head/sys/dev/fdt/fdt_clock.c
  stable/10/sys/dev/fdt/fdt_clock.h
     - copied unchanged from r270957, head/sys/dev/fdt/fdt_clock.h
  stable/10/sys/dev/fdt/fdt_clock_if.m
     - copied unchanged from r270957, head/sys/dev/fdt/fdt_clock_if.m
Modified:
  stable/10/sys/conf/files
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/conf/files
==============================================================================
--- stable/10/sys/conf/files    Sun Oct 26 02:09:58 2014        (r273656)
+++ stable/10/sys/conf/files    Sun Oct 26 02:19:03 2014        (r273657)
@@ -1371,6 +1371,8 @@ dev/fatm/if_fatm.c                optional fatm pci
 dev/fb/fbd.c                   optional fbd | vt
 dev/fb/fb_if.m                 standard
 dev/fb/splash.c                        optional sc splash
+dev/fdt/fdt_clock.c            optional fdt
+dev/fdt/fdt_clock_if.m         optional fdt
 dev/fdt/fdt_common.c           optional fdt
 dev/fdt/fdt_slicer.c           optional fdt cfi | fdt nand
 dev/fdt/fdt_static_dtb.S       optional fdt fdt_dtb_static \

Copied and modified: stable/10/sys/dev/fdt/fdt_clock.c (from r270957, 
head/sys/dev/fdt/fdt_clock.c)
==============================================================================
--- head/sys/dev/fdt/fdt_clock.c        Tue Sep  2 03:23:05 2014        
(r270957, copy source)
+++ stable/10/sys/dev/fdt/fdt_clock.c   Sun Oct 26 02:19:03 2014        
(r273657)
@@ -32,6 +32,7 @@
 #include <sys/lock.h>
 #include <sys/mutex.h>
 #include <sys/queue.h>
+#include <sys/systm.h>
 
 #include <dev/ofw/ofw_bus.h>
 #include <dev/ofw/ofw_bus_subr.h>
@@ -119,7 +120,7 @@ fdt_clock_get_info(device_t consumer, in
                         * override anything it wants to).
                         */
                        clocknum = clks[n + 1];
-                       memset(info, 0, sizeof(*info));
+                       bzero(info, sizeof(*info));
                        info->provider = clockdev;
                        info->index = clocknum;
                        info->name = "";
@@ -148,13 +149,13 @@ void
 fdt_clock_register_provider(device_t provider)
 {
 
-       OF_device_register_xref(OF_xref_from_node(provider), provider);
+       OF_device_register_xref(OF_xref_from_device(provider), provider);
 }
 
 void
 fdt_clock_unregister_provider(device_t provider)
 {
 
-       OF_device_register_xref(OF_xref_from_node(provider), NULL);
+       OF_device_register_xref(OF_xref_from_device(provider), NULL);
 }
 

Copied: stable/10/sys/dev/fdt/fdt_clock.h (from r270957, 
head/sys/dev/fdt/fdt_clock.h)
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ stable/10/sys/dev/fdt/fdt_clock.h   Sun Oct 26 02:19:03 2014        
(r273657, copy of r270957, head/sys/dev/fdt/fdt_clock.h)
@@ -0,0 +1,55 @@
+/*-
+ * Copyright (c) 2014 Ian Lepore <[email protected]>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef DEV_FDT_CLOCK_H
+#define DEV_FDT_CLOCK_H
+
+#include "fdt_clock_if.h"
+
+/*
+ * Get info about the Nth clock listed in consumer's "clocks" property.
+ *
+ * Returns 0 on success, ENXIO if clock #n not found.
+ */
+int fdt_clock_get_info(device_t consumer, int n, struct fdt_clock_info *info);
+
+/*
+ * Look up "clocks" property in consumer's fdt data and enable or disable all
+ * configured clocks.
+ */
+int fdt_clock_enable_all(device_t consumer);
+int fdt_clock_disable_all(device_t consumer);
+
+/*
+ * [Un]register the given device instance as a driver that implements the
+ * fdt_clock interface.
+ */
+void fdt_clock_register_provider(device_t provider);
+void fdt_clock_unregister_provider(device_t provider);
+
+#endif /* DEV_FDT_CLOCK_H */
+

Copied: stable/10/sys/dev/fdt/fdt_clock_if.m (from r270957, 
head/sys/dev/fdt/fdt_clock_if.m)
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ stable/10/sys/dev/fdt/fdt_clock_if.m        Sun Oct 26 02:19:03 2014        
(r273657, copy of r270957, head/sys/dev/fdt/fdt_clock_if.m)
@@ -0,0 +1,81 @@
+#-
+# Copyright (c) 2014 Ian Lepore
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+
+#include <sys/types.h>
+
+#
+# This is the interface that fdt_clock drivers provide to other drivers.
+# In this context, clock refers to a clock signal provided to some other
+# hardware component within the system.  They are most often found within
+# embedded processors that have on-chip IO controllers.
+#
+
+INTERFACE fdt_clock;
+
+HEADER {
+
+       enum {
+               FDT_CIFLAG_RUNNING =    0x01,
+       };
+
+       struct fdt_clock_info {
+               device_t        provider;
+               uint32_t        index;
+               const char *    name;         /* May be "", will not be NULL. */
+               uint32_t        flags;
+               uint64_t        frequency;    /* In Hz. */
+       };
+}
+
+#
+# Enable the specified clock.
+# Returns 0 on success or a standard errno value.
+#
+METHOD int enable {
+       device_t        provider;
+       int             index;
+};
+
+#
+# Disable the specified clock.
+# Returns 0 on success or a standard errno value.
+#
+METHOD int disable {
+       device_t        provider;
+       int             index;
+};
+
+#
+# Returns information about the current operational state of specified clock.
+#
+METHOD int get_info {
+       device_t        provider;
+       int             index;
+       struct fdt_clock_info *info;
+};
+
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to