Author: ganbold
Date: Mon Mar  3 11:00:52 2014
New Revision: 262708
URL: http://svnweb.freebsd.org/changeset/base/262708

Log:
  Add gpio and clock bits for A10/A20's EMAC ethernet controller driver, such 
as:
  - EMAC gpio configuration
  - EMAC clock activation
  
  Approved by:  stas (mentor)

Added:
  head/sys/arm/allwinner/a10_gpio.h   (contents, props changed)
Modified:
  head/sys/arm/allwinner/a10_clk.c
  head/sys/arm/allwinner/a10_clk.h
  head/sys/arm/allwinner/a10_gpio.c

Modified: head/sys/arm/allwinner/a10_clk.c
==============================================================================
--- head/sys/arm/allwinner/a10_clk.c    Mon Mar  3 09:57:04 2014        
(r262707)
+++ head/sys/arm/allwinner/a10_clk.c    Mon Mar  3 11:00:52 2014        
(r262708)
@@ -127,7 +127,7 @@ a10_clk_usb_activate(void)
        uint32_t reg_value;
 
        if (sc == NULL)
-               return ENXIO;
+               return (ENXIO);
 
        /* Gating AHB clock for USB */
        reg_value = ccm_read_4(sc, CCM_AHB_GATING0);
@@ -154,7 +154,7 @@ a10_clk_usb_deactivate(void)
        uint32_t reg_value;
 
        if (sc == NULL)
-               return ENXIO;
+               return (ENXIO);
 
        /* Disable clock for USB */
        reg_value = ccm_read_4(sc, CCM_USB_CLK);
@@ -173,3 +173,19 @@ a10_clk_usb_deactivate(void)
        return (0);
 }
 
+int
+a10_clk_emac_activate(void) {
+       struct a10_ccm_softc *sc = a10_ccm_sc;
+       uint32_t reg_value;
+
+       if (sc == NULL)
+               return (ENXIO);
+
+       /* Gating AHB clock for EMAC */
+       reg_value = ccm_read_4(sc, CCM_AHB_GATING0);
+       reg_value |= CCM_AHB_GATING_EMAC;
+       ccm_write_4(sc, CCM_AHB_GATING0, reg_value);
+
+       return (0);
+}
+

Modified: head/sys/arm/allwinner/a10_clk.h
==============================================================================
--- head/sys/arm/allwinner/a10_clk.h    Mon Mar  3 09:57:04 2014        
(r262707)
+++ head/sys/arm/allwinner/a10_clk.h    Mon Mar  3 11:00:52 2014        
(r262708)
@@ -103,6 +103,7 @@
 #define CCM_AHB_GATING_USB0    (1 << 0)
 #define CCM_AHB_GATING_EHCI0   (1 << 1)
 #define CCM_AHB_GATING_EHCI1   (1 << 3)
+#define CCM_AHB_GATING_EMAC    (1 << 17)
 
 #define CCM_USB_PHY            (1 << 8)
 #define CCM_USB0_RESET         (1 << 0)
@@ -111,5 +112,6 @@
 
 int a10_clk_usb_activate(void);
 int a10_clk_usb_deactivate(void);
+int a10_clk_emac_activate(void);
 
 #endif /* _A10_CLK_H_ */

Modified: head/sys/arm/allwinner/a10_gpio.c
==============================================================================
--- head/sys/arm/allwinner/a10_gpio.c   Mon Mar  3 09:57:04 2014        
(r262707)
+++ head/sys/arm/allwinner/a10_gpio.c   Mon Mar  3 11:00:52 2014        
(r262708)
@@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$");
 #include <dev/ofw/ofw_bus_subr.h>
 
 #include "gpio_if.h"
+#include "a10_gpio.h"
 
 /*
  * A10 have 9 banks of gpio.
@@ -102,6 +103,8 @@ struct a10_gpio_softc {
 #define        A10_GPIO_GP_INT_STA             0x214
 #define        A10_GPIO_GP_INT_DEB             0x218
 
+static struct a10_gpio_softc *a10_gpio_sc;
+
 #define        A10_GPIO_WRITE(_sc, _off, _val)         \
     bus_space_write_4(_sc->sc_bst, _sc->sc_bsh, _off, _val)
 #define        A10_GPIO_READ(_sc, _off)                \
@@ -473,6 +476,9 @@ a10_gpio_attach(device_t dev)
 
        device_add_child(dev, "gpioc", device_get_unit(dev));
        device_add_child(dev, "gpiobus", device_get_unit(dev));
+
+       a10_gpio_sc = sc;
+
        return (bus_generic_attach(dev));
 
 fail:
@@ -518,3 +524,19 @@ static driver_t a10_gpio_driver = {
 };
 
 DRIVER_MODULE(a10_gpio, simplebus, a10_gpio_driver, a10_gpio_devclass, 0, 0);
+
+int
+a10_emac_gpio_config(uint32_t pin)
+{
+       struct a10_gpio_softc *sc = a10_gpio_sc;
+
+       if (sc == NULL)
+               return (ENXIO);
+
+       /* Configure pin mux settings for MII. */
+       A10_GPIO_LOCK(sc);
+       a10_gpio_set_function(sc, pin, A10_GPIO_PULLDOWN);
+       A10_GPIO_UNLOCK(sc);
+
+       return (0);
+}

Added: head/sys/arm/allwinner/a10_gpio.h
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/arm/allwinner/a10_gpio.h   Mon Mar  3 11:00:52 2014        
(r262708)
@@ -0,0 +1,34 @@
+/*-
+ * Copyright (c) 2013 Ganbold Tsagaankhuu <ganb...@gmail.com>
+ * 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$
+ */
+
+#ifndef        _A10_GPIO_H_
+#define        _A10_GPIO_H_
+
+int a10_emac_gpio_config(uint32_t pin);
+
+#endif
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to