Re: help: BeagleBoard xM RevC ethernet port

2012-02-23 Thread Richard Watts
On 22/02/12 22:00, Kevin Hilman wrote:
 Peter Ujfalusi peter.ujfal...@ti.com writes:
 
 Hi,

 I hoped that time will solve this, but so far no luck. I just can not
 get the ethernet port (along with the USB host ports) working on my xM RevC.
 What is the trick to get it working on 3.3-rc3?

 There seams to be some configuration issue:

 [1.437530] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
 [1.444671] ehci_hcd: block sizes: qh 64 qtd 96 itd 160 sitd 96
 [1.451354] ehci-omap ehci-omap.0: failed to get ehci port0 regulator
 [1.458282] ehci-omap ehci-omap.0: failed to get ehci port1 regulator
 
 
 The first thing I try when I see these regulator failures is to add
 CONFIG_REGULATOR_DUMMY=y to the .config to see if that helps.  If so,
 then the board file needs some help configuring the right regulators.
 
 Kevin
 --

 Apologies for the malformed patch, but I don't have time to clean it up
this morning (or test it in its cleaned state); however, the following
fixes the problem for me.

 It used to be masked because u-boot turns the regulator on to activate
ethernet on Beagle xM and no-one ever turns it off again, but some versions
of u-boot don't identify xM rev C correctly, so never turn it on ..

 Anyway, it's neater for the kernel to know what it's doing. And removes
a whole two lines of kernel startup output :-)


Richard.
---
commit 39d26ad563023ac06e8aaaf154378c373187
Author: Richard Watts r...@kynesim.co.uk
Date:   Fri Jan 20 12:27:59 2012 +

Turn on the USB regulator on Beagle xM explicitly, when the USB
subsystem asks for it, rather than relying on u-boot to do it.

diff --git a/arch/arm/mach-omap2/board-omap3beagle.c 
b/arch/arm/mach-omap2/board-omap3beagle.c
index 4a71cb7..69ed6a0 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -362,11 +362,32 @@ static struct regulator_init_data beagle_vsim = {
.consumer_supplies  = beagle_vsim_supply,
 };

+static struct regulator_consumer_supply beagle_usb_supply[] = {
+REGULATOR_SUPPLY(hsusb0, ehci-omap.0),
+REGULATOR_SUPPLY(hsusb1, ehci-omap.0)
+};
+
+static struct regulator_init_data usb_power = {
+.constraints = {
+.min_uV = 180,
+.max_uV = 180,
+.valid_modes_mask = REGULATOR_MODE_NORMAL,
+.valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
+| REGULATOR_CHANGE_MODE
+| REGULATOR_CHANGE_STATUS,
+},
+.num_consumer_supplies = ARRAY_SIZE(beagle_usb_supply),
+.consumer_supplies = beagle_usb_supply
+};
+
+
+
 static struct twl4030_platform_data beagle_twldata = {
/* platform_data for children goes here */
.gpio   = beagle_gpio_data,
.vmmc1  = beagle_vmmc1,
.vsim   = beagle_vsim,
+.vaux2  = usb_power,
 };

 static struct i2c_board_info __initdata beagle_i2c_eeprom[] =

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/1] Fix sprz319 erratum 2.1

2012-02-20 Thread Richard Watts

There is an erratum in DM3730 which results in the
EHCI USB PLL (DPLL5) not updating sufficiently frequently; this
leads to USB PHY clock drift and once the clock has drifted far
enough, the PHY's ULPI interface stops responding and USB
drops out. This is manifested on a Beagle xM by having the attached
SMSC9514 report 'Cannot enable port 2. Maybe the USB cable is bad?'
or similar.

The fix is to carefully adjust your DPLL5 settings so as to
keep the PHY clock as close as possible to 120MHz over the long
term; TI SPRZ319e gives a table of such settings and this patch
applies that table to systems with a 13MHz or a 26MHz clock,
thus fixing the issue (inasfar as it can be fixed) on Beagle xM
and Overo Firestorm.

Signed-off-by: Richard Watts r...@kynesim.co.uk
---

 This is my first time submitting a kernel patch, so treat the
following with the respect it (doesn't) deserve. The way I'm
setting the dpll5_m2clk is particularly horrid, but the
previous code was not much better. An earlier version of
this patch appeared on the beagleboard mailing list.


 arch/arm/mach-omap2/clkt_clksel.c|   15 
 arch/arm/mach-omap2/clock.h  |7 
 arch/arm/mach-omap2/clock3xxx.c  |   65 +
 arch/arm/mach-omap2/clock3xxx.h  |1 +
 arch/arm/mach-omap2/clock3xxx_data.c |2 +-
 arch/arm/mach-omap2/dpll3xxx.c   |2 +-
 6 files changed, 82 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-omap2/clkt_clksel.c 
b/arch/arm/mach-omap2/clkt_clksel.c
index e25364d..e378fe7 100644
--- a/arch/arm/mach-omap2/clkt_clksel.c
+++ b/arch/arm/mach-omap2/clkt_clksel.c
@@ -460,6 +460,21 @@ int omap2_clksel_set_rate(struct clk *clk, unsigned long 
rate)
return 0;
 }

+int omap2_clksel_force_divisor(struct clk *clk, int new_div)
+{
+   u32 field_val;
+
+   field_val = _divisor_to_clksel(clk, new_div);
+   if (field_val == ~0)
+   return -EINVAL;
+
+   _write_clksel_reg(clk, field_val);
+
+   clk-rate = clk-parent-rate / new_div;
+
+   return 0;
+}
+
 /*
  * Clksel parent setting function - not passed in struct clk function
  * pointer - instead, the OMAP clock code currently assumes that any
diff --git a/arch/arm/mach-omap2/clock.h b/arch/arm/mach-omap2/clock.h
index b8c2a68..5b149cd 100644
--- a/arch/arm/mach-omap2/clock.h
+++ b/arch/arm/mach-omap2/clock.h
@@ -61,6 +61,12 @@ void omap3_dpll_allow_idle(struct clk *clk);
 void omap3_dpll_deny_idle(struct clk *clk);
 u32 omap3_dpll_autoidle_read(struct clk *clk);
 int omap3_noncore_dpll_set_rate(struct clk *clk, unsigned long rate);
+#if CONFIG_ARCH_OMAP3
+int omap3_noncore_dpll_program(struct clk *clk, u16 m, u8 n, u16 freqsel);
+/* If you are using this function and not on OMAP3, you are
+ * Doing It Wrong(tm), so there is no stub.
+ */
+#endif
 int omap3_noncore_dpll_enable(struct clk *clk);
 void omap3_noncore_dpll_disable(struct clk *clk);
 int omap4_dpllmx_gatectrl_read(struct clk *clk);
@@ -86,6 +92,7 @@ unsigned long omap2_clksel_recalc(struct clk *clk);
 long omap2_clksel_round_rate(struct clk *clk, unsigned long target_rate);
 int omap2_clksel_set_rate(struct clk *clk, unsigned long rate);
 int omap2_clksel_set_parent(struct clk *clk, struct clk *new_parent);
+int omap2_clksel_force_divisor(struct clk *clk, int new_div);

 /* clkt_iclk.c public functions */
 extern void omap2_clkt_iclk_allow_idle(struct clk *clk);
diff --git a/arch/arm/mach-omap2/clock3xxx.c b/arch/arm/mach-omap2/clock3xxx.c
index 952c3e0..d5be086 100644
--- a/arch/arm/mach-omap2/clock3xxx.c
+++ b/arch/arm/mach-omap2/clock3xxx.c
@@ -40,6 +40,60 @@
 /* needed by omap3_core_dpll_m2_set_rate() */
 struct clk *sdrc_ick_p, *arm_fck_p;

+struct dpll_settings {
+   int rate, m, n, f;
+};
+
+
+static int omap3_dpll5_apply_erratum21(struct clk *clk, struct clk *dpll5_m2)
+{
+   struct clk *sys_clk;
+   int i, rv;
+   static const struct dpll_settings precomputed[] = {
+   /* From DM3730 errata (sprz319e), table 36
+   * +1 is because the values in the table are register values;
+   * dpll_program() will subtract one from what we give it,
+   * so ...
+   */
+   { 1300, 443+1, 5+1, 8 },
+   { 2600, 443+1, 11+1, 8 }
+   };
+
+   sys_clk = clk_get(NULL, sys_ck);
+
+   for (i = 0 ; i  (sizeof(precomputed)/sizeof(struct dpll_settings)) ;
+   ++i) {
+   const struct dpll_settings *d = precomputed[i];
+   if (sys_clk-rate == d-rate) {
+   rv =  omap3_noncore_dpll_program(clk, d-m , d-n, 0);
+   if (rv)
+   return 1;
+   rv =  omap2_clksel_force_divisor(dpll5_m2 , d-f);
+   return 1;
+   }
+   }
+   return 0;
+}
+
+int omap3_dpll5_set_rate(struct clk *clk, unsigned long rate)
+{
+   struct clk *dpll5_m2;
+   int rv