Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/arm/nvidia Support fractional dividers. This lets u...
details: https://anonhg.NetBSD.org/src/rev/2ea4728a7131
branches: trunk
changeset: 339465:2ea4728a7131
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Thu Jul 23 18:22:05 2015 +0000
description:
Support fractional dividers. This lets us use 48MHz for SDMMC HS mode
instead of 45.333MHz.
diffstat:
sys/arch/arm/nvidia/tegra_car.c | 16 +++++++++-------
sys/arch/arm/nvidia/tegra_sdhc.c | 11 +++--------
sys/arch/arm/nvidia/tegra_var.h | 4 ++--
3 files changed, 14 insertions(+), 17 deletions(-)
diffs (108 lines):
diff -r 58b4de6d5c7c -r 2ea4728a7131 sys/arch/arm/nvidia/tegra_car.c
--- a/sys/arch/arm/nvidia/tegra_car.c Thu Jul 23 17:12:16 2015 +0000
+++ b/sys/arch/arm/nvidia/tegra_car.c Thu Jul 23 18:22:05 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_car.c,v 1.22 2015/07/23 14:30:06 jmcneill Exp $ */
+/* $NetBSD: tegra_car.c,v 1.23 2015/07/23 18:22:05 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -29,7 +29,7 @@
#include "locators.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tegra_car.c,v 1.22 2015/07/23 14:30:06 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_car.c,v 1.23 2015/07/23 18:22:05 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -374,13 +374,13 @@
const uint32_t src = bus_space_read_4(bst, bsh, src_reg);
- const u_int div = (__SHIFTOUT(src, CAR_CLKSRC_SDMMC_DIV) / 2) + 1;
+ const u_int div = __SHIFTOUT(src, CAR_CLKSRC_SDMMC_DIV) + 2;
- return tegra_car_pllp0_rate() / div;
+ return (tegra_car_pllp0_rate() * 2) / div;
}
int
-tegra_car_periph_sdmmc_set_div(u_int port, u_int div)
+tegra_car_periph_sdmmc_set_rate(u_int port, u_int rate)
{
bus_space_tag_t bst;
bus_space_handle_t bsh;
@@ -388,7 +388,7 @@
u_int dev_bit;
uint32_t src;
- KASSERT(div > 0);
+ KASSERT(rate > 0);
tegra_car_get_bs(&bst, &bsh);
@@ -425,10 +425,12 @@
/* enable clk */
bus_space_write_4(bst, bsh, enb_reg, dev_bit);
+ const u_int div = howmany(tegra_car_pllp0_rate() * 2, rate) - 2;
+
/* update clk div */
src = __SHIFTIN(CAR_CLKSRC_SDMMC_SRC_PLLP_OUT0,
CAR_CLKSRC_SDMMC_SRC);
- src |= __SHIFTIN((div - 1) * 2, CAR_CLKSRC_SDMMC_DIV);
+ src |= __SHIFTIN(div, CAR_CLKSRC_SDMMC_DIV);
bus_space_write_4(bst, bsh, src_reg, src);
/* leave reset */
diff -r 58b4de6d5c7c -r 2ea4728a7131 sys/arch/arm/nvidia/tegra_sdhc.c
--- a/sys/arch/arm/nvidia/tegra_sdhc.c Thu Jul 23 17:12:16 2015 +0000
+++ b/sys/arch/arm/nvidia/tegra_sdhc.c Thu Jul 23 18:22:05 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_sdhc.c,v 1.6 2015/05/30 18:53:39 jmcneill Exp $ */
+/* $NetBSD: tegra_sdhc.c,v 1.7 2015/07/23 18:22:05 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -29,7 +29,7 @@
#include "locators.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tegra_sdhc.c,v 1.6 2015/05/30 18:53:39 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_sdhc.c,v 1.7 2015/07/23 18:22:05 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -122,12 +122,7 @@
if (sc->sc_pin_wp)
sc->sc.sc_vendor_write_protect = tegra_sdhc_write_protect;
-#if notyet
- tegra_car_periph_sdmmc_set_div(sc->sc_port, 1);
-#else
- const u_int div = howmany(tegra_car_pllp0_rate() / 1000, 50000);
- tegra_car_periph_sdmmc_set_div(sc->sc_port, div);
-#endif
+ tegra_car_periph_sdmmc_set_rate(sc->sc_port, 50000000);
sc->sc.sc_clkbase = tegra_car_periph_sdmmc_rate(sc->sc_port) / 1000;
aprint_naive("\n");
diff -r 58b4de6d5c7c -r 2ea4728a7131 sys/arch/arm/nvidia/tegra_var.h
--- a/sys/arch/arm/nvidia/tegra_var.h Thu Jul 23 17:12:16 2015 +0000
+++ b/sys/arch/arm/nvidia/tegra_var.h Thu Jul 23 18:22:05 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_var.h,v 1.22 2015/07/08 01:23:28 jmcneill Exp $ */
+/* $NetBSD: tegra_var.h,v 1.23 2015/07/23 18:22:05 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -96,7 +96,7 @@
u_int tegra_car_plld2_rate(void);
u_int tegra_car_uart_rate(u_int);
u_int tegra_car_periph_sdmmc_rate(u_int);
-int tegra_car_periph_sdmmc_set_div(u_int, u_int);
+int tegra_car_periph_sdmmc_set_rate(u_int, u_int);
int tegra_car_periph_usb_enable(u_int);
void tegra_car_periph_hda_enable(void);
void tegra_car_periph_sata_enable(void);
Home |
Main Index |
Thread Index |
Old Index