1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-30 12:04:07 +00:00

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)
This commit is contained in:
Ganbold Tsagaankhuu 2014-03-03 11:00:52 +00:00
parent fd13916c8b
commit 79690a92d0
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=262708
4 changed files with 76 additions and 2 deletions

View File

@ -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);
}

View File

@ -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_ */

View File

@ -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);
}

View File

@ -0,0 +1,34 @@
/*-
* Copyright (c) 2013 Ganbold Tsagaankhuu <ganbold@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