* Question: Custom DAI driver for AM35xx using McBSP
@ 2012-02-29 4:11 CF Adad
2012-02-29 17:27 ` CF Adad
0 siblings, 1 reply; 9+ messages in thread
From: CF Adad @ 2012-02-29 4:11 UTC (permalink / raw)
To: linux-omap@vger.kernel.org
All,
Please forgive me if I don't get this post quite right. This is my first time posting to the mailing lists.
My team is working on a driver that will be used to interface a cell modem's digital audio interface (DAI) to a McBSP port on an AM3517. Our goal is to be able to support multiple such interfaces down the road. For now, however, we will be satisfied just getting the one we have on our demo board (McBSP2) to work 100%.
The driver should be VERY simple: The cell modem has a 4-wire DAI port that behaves much like any other PCM hook-up (CLK, FS, TX, RX), and we simply want that raw data pulled into userspace via ALSA for handling. The DAI on the modem has a fixed configuration:
- Clock is master, fixed at 256kHz
- Frame sync is master, fixed 125us frame
duration (8kHz): 32 bits of total data; first 16 bits are valid (while
FS is high), following 16 are "don't care" (while FS low)
- 16-bit linear samples, sent MSB first
- "Long Frame" sync: transmit and receive occur simultaneously while the common FS line is active (high).
- TX data with 0-bit delay; start at the rising edge of the clock, while FS is high.
- RX data with 0-bit delay; sample at the falling edge of the clock, while FS is high.
(We have posted to the TI E2E forums and sought their help, but have yet to receive a response. Our E2E posts contain much more detail which may be useful to anyone willing to take a look here. They can be found here: http://e2e.ti.com/support/dsp/sitara_arm174_microprocessors/f/416/t/165965.aspx.)
So, obviously the McBSP has to be configured as a slave and setup to support this fixed signaling standard. The only thing that I know of that's a little unique here is the "long frame sync". Most PCM setups I've seen (like i2s) use a "short frame sync" instead.
There is no "CODEC" necessary per se, as all we want to do for now is pull the raw PCM data into userspace for ALSA handling. So, we have not defined any volume controls, etc. Similarly, power mangement is not our primary concern. So, for now, we've ignored DAPM.
The drivers we have pulled together, shown below, are based heavily off other PCM drivers we found (like for S/PDIF or bluetooth headsets) and immediately gave us working playback. We were able to play audio using the "aplay <wavefile>" command almost immediately.
*** However, when recording ("arecord -f S16_LE -r 8000 -c 1 <wavefile>"), we have never been able to get anything but silence (0x00). ***
We are presently using a snapshotted version of Linux 3.2-rc6 from the linux-omap tree. We plan on upgrading as soon as we can straighten this out and prove it works. We simply don't want to make changes to a working setup mid-debug so as to avoid adding any other issues into the mix.
We have enabled a significant amount of debugging, and as best we can tell, we are getting IRQs from omap_pcm_dma_irq() and we are actually reading nothing but 0s in the data block. We determined this by dumping the bytes as they came into userspace via snd_pcm_lib_read_transfer(). The data going onto the wire is non-zero, as an o-scope clearly shows bits changing. We have checked the pin mux maps (even making the line a GPIO output to toggle it to make sure), and about every other setting we can think of. If we disconnect either the CLK or FS wire from the McBSP, everything stops. So, we know the control lines are being monitored. What we do not know, is whether or not they're being interpretted correctly. Our gut tells us they are not. If we allow our record to run long enough (> 6-10 seconds), we do start receiving an overrun or two, and we've not sorted out the cause of that yet.
Our first expectation is that something is not setup properly in the McBSP. Since the McBSP is being configured by Linux in our case, we figured we'd take it to the experts here to see if you could identify where we've gone wrong.
THANKS IN ADVANCE FOR YOU HELP!!!
The code below is for the two driver files we have come up with to date. (Again, our apologies that they are not compliant with the latest combined omap-mcbsp stuff being released as we speak.):
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< celldai-soc.c >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
/*
* celldai-soc.c -- ALSA SoC audio pcm for OMAP3/AM35xx
*
*
* Based on sound/soc/omap/overo.c by Steve Sakoman
* and am3517evm.c by Anuj Aggarwal <anuj.aggarwal@ti.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#include <linux/init.h>
#include <linux/clk.h>
#include <linux/platform_device.h>
#include <linux/module.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/soc.h>
/*** includes here down, needed??? ***/
#include <asm/mach-types.h>
#include <mach/hardware.h>
#include <mach/gpio.h>
//#include <plat/mcbsp.h>
#include "omap-mcbsp.h"
//#include "omap-pcm.h"
static struct platform_device *celldai_snd_device;
static struct platform_device *celldai_codec_device;
static int celldai_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
/* we really do not have a "codec", it's an external device with no control & a fixed configuration */
// struct snd_soc_dai *codec_dai = rtd->codec_dai;
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
unsigned int fmt = 0;
int ret;
switch (params_channels(params)) {
case 1: /* voice only - 8kHz, S16_LE, mono */
fmt = SND_SOC_DAIFMT_LEFT_J |
SND_SOC_DAIFMT_IB_NF |
SND_SOC_DAIFMT_CBM_CFM;
break;
default:
return -EINVAL;
break;
}
#if 0 /*** I don't think we'll be configuring anything with the audio device from the kernel ***/
/* Set codec DAI configuration */
ret = snd_soc_dai_set_fmt(codec_dai, fmt);
if (ret < 0) {
printk(KERN_ERR "can't set codec DAI configuration\n");
return ret;
}
/* Set the codec system clock for DAC and ADC */
ret = snd_soc_dai_set_sysclk(codec_dai, 0, 26000000,
SND_SOC_CLOCK_IN);
if (ret < 0) {
printk(KERN_ERR "can't set codec system clock\n");
return ret;
}
#endif
/* Set cpu DAI configuration */
ret = snd_soc_dai_set_fmt(cpu_dai, fmt);
if (ret < 0) {
printk(KERN_ERR "can't set cpu DAI configuration\n");
return ret;
}
#if 0 /*** these next 2 are valid only for mcbsp1 (0 to the driver),
as other mcbsp's lack separate CLKR/FSR lines ***/
/* set cpu CLKR & FSR as inputs (unused) */
ret = snd_soc_dai_set_sysclk(cpu_dai, OMAP_MCBSP_CLKR_SRC_CLKX, 0,
SND_SOC_CLOCK_IN);
if (ret < 0) {
printk(KERN_ERR "can't set CPU system clock OMAP_MCBSP_CLKR_SRC_CLKX\n");
return ret;
}
snd_soc_dai_set_sysclk(cpu_dai, OMAP_MCBSP_FSR_SRC_FSX, 0,
SND_SOC_CLOCK_IN);
if (ret < 0) {
printk(KERN_ERR "can't set CPU system clock OMAP_MCBSP_FSR_SRC_FSX\n");
return ret;
}
#endif
#if 0 /*** I believe these are NOT needed since McBSP is slave! ***/
/* Set McBSP clock to external */
// note, final parameter appears ignored.
ret = snd_soc_dai_set_sysclk(cpu_dai, OMAP_MCBSP_SYSCLK_CLKX_EXT,
256 * params_rate(params), SND_SOC_CLOCK_IN);
if (ret < 0) {
printk(KERN_ERR "can't set cpu DAI clock source: OMAP_MCBSP_SYSCLK_CLKX_EXT\n"); // was 0
return ret;
}
/* Set cpu DAI master clock divisor */
ret = snd_soc_dai_set_clkdiv(cpu_dai, OMAP_MCBSP_CLKGDV, 8); // was 1
if (ret < 0) {
printk(KERN_ERR "can't set cpu DAI clock divider: OMAP_MCBSP_CLKGDV\n");
return ret;
}
#endif
return 0;
}
static struct snd_soc_ops celldai_ops = {
.hw_params = celldai_hw_params,
};
/* Digital audio interface glue - connects codec <--> CPU */
static struct snd_soc_dai_link celldai_dai = {
.name = "cell_dai",
.stream_name = "cell_dai",
.cpu_dai_name = "omap-mcbsp-dai.1",
.platform_name = "omap-pcm-audio",
.codec_dai_name = "celldai-codec-dai",
.codec_name = "celldai-codec",
.ops = &celldai_ops,
};
/* Audio machine driver */
static struct snd_soc_card snd_soc_celldai = {
.name = "celldai",
.owner = THIS_MODULE,
.dai_link = &celldai_dai,
.num_links = 1,
};
static int __init celldai_soc_init(void)
{
int ret = 0;
printk(KERN_DEBUG "celldai_soc_init\n");
celldai_codec_device = platform_device_alloc("celldai-codec", -1);
if (!celldai_codec_device)
return -ENOMEM;
ret = platform_device_add(celldai_codec_device);
if (ret)
goto err1;
celldai_snd_device = platform_device_alloc("soc-audio", -1);
if (!celldai_snd_device) {
printk(KERN_ERR "Platform device allocation failed\n");
return -ENOMEM;
}
platform_set_drvdata(celldai_snd_device, &snd_soc_celldai);
ret = platform_device_add(celldai_snd_device);
if (ret)
goto err2;
printk(KERN_INFO "celldai SoC init\n");
return 0;
err1:
printk(KERN_ERR "Unable to add platform device (codec)\n");
platform_device_put(celldai_codec_device);
err2:
printk(KERN_ERR "Unable to add platform device (snd)\n");
platform_device_put(celldai_snd_device);
return ret;
}
static void __exit celldai_soc_exit(void)
{
printk(KERN_DEBUG "celldai_soc_exit\n");
platform_device_unregister(celldai_snd_device);
platform_device_unregister(celldai_codec_device);
}
module_init(celldai_soc_init);
module_exit(celldai_soc_exit);
MODULE_AUTHOR("TBD");
MODULE_DESCRIPTION("ALSA SoC - Custom Cell DAI");
MODULE_LICENSE("GPL");
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< celldai-codec.c
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
/*
* celldai-codec.c -- SOC codec driver for cell modem
*
*
* based on spdif_transciever.c by Steve Chen <schen@mvista.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/slab.h>
#include <sound/soc.h>
#include <sound/pcm.h>
#include <sound/initval.h>
#define DRV_NAME "celldai-codec"
/***********************************************************************
* This device really does not need a CODEC. There definitely is to "encoding"
* or "decoding" being done here. All that is desired is a passthrough for the raw
* PCM. Likewise, there is no interconnect to the cell modem (i2c, SPI, etc)
* and it is not configurable. This file is really just a stub.
***********************************************************************/
static struct snd_soc_codec_driver soc_codec_celldai_codec = {
};
static struct snd_soc_dai_driver pcm_stub_dai = {
.name = "celldai-codec-dai",
.playback = {
.stream_name = "Playback",
.channels_min = 1,
.channels_max = 1,
.rates = SNDRV_PCM_RATE_8000,
.formats = SNDRV_PCM_FMTBIT_S16_LE,
},
.capture = {
.stream_name = "Capture",
.channels_min = 1,
.channels_max = 1,
.rates = SNDRV_PCM_RATE_8000,
.formats = SNDRV_PCM_FMTBIT_S16_LE,
},
};
static int celldai_codec_probe(struct platform_device *pdev)
{
return snd_soc_register_codec(&pdev->dev, &soc_codec_celldai_codec,
&pcm_stub_dai, 1);
}
static int celldai_codec_remove(struct platform_device *pdev)
{
snd_soc_unregister_codec(&pdev->dev);
return 0;
}
static struct platform_driver celldai_codec_driver = {
.probe = celldai_codec_probe,
.remove = celldai_codec_remove,
.driver = {
.name = DRV_NAME,
.owner = THIS_MODULE,
},
};
static int __init dit_modinit(void)
{
return platform_driver_register(&celldai_codec_driver);
}
static void __exit dit_exit(void)
{
platform_driver_unregister(&celldai_codec_driver);
}
module_init(dit_modinit);
module_exit(dit_exit);
MODULE_AUTHOR("TBD");
MODULE_DESCRIPTION("Custom Cell DAI 'codec' driver");
MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:" DRV_NAME);
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: Question: Custom DAI driver for AM35xx using McBSP 2012-02-29 4:11 Question: Custom DAI driver for AM35xx using McBSP CF Adad @ 2012-02-29 17:27 ` CF Adad 2012-03-01 17:13 ` CF Adad 0 siblings, 1 reply; 9+ messages in thread From: CF Adad @ 2012-02-29 17:27 UTC (permalink / raw) To: linux-omap@vger.kernel.org One note of clarification: As mentioned in the email above, the only "non-standard" piece to this signaling is likely the "long frame sync". As shown on the modem's timing diagram (posted on the E2E forums here: http://e2e.ti.com/resized-image.ashx/__size/550x0/__key/CommunityServer-Discussions-Components-Files/447/2476.clk_5F00_fs_5F00_timing.jpg), the FS pulse is active (high) for 16 bits and then low for another 16 bits. At 8kHz, that makes the frame period 125us. All TX and RX happens simultaneously while FS is active (high), and _nothing_ happens while it is low. We have interpretted this as requiring a frame width (FWID) of 16 [well, 15+1 in the McBSP] and a frame period (FPER) of 32 [or, 31+1 in the McBSP]. Since the AM3517 is a slave, however, we do not expect to need the SRG. So we're not sure how important these variables are to the McBSP config. Should other settings be used? We have studied the /sound/soc/omap/omap-mcbsp.c file in great detail, and the only place we can see a possible misconfiguration for us is in the calculation of framesize, which Linux uses to setup FWID and FPER. In the existing code, framesize is calculated as "wlen * channels". So, for a mono signal like ours, our frame ends up only 16 bits wide, not 32. We're not sure how big of deal this is, as if the code is simply looking for the rising edge of the FS pulse, then it should not matter how long the FS is down for before going high again. Regardless, for testing, we forced the framesize calculation on line 373 of omap-mcbsp.c to be: framesize = wlen * 2; // 32 We have tried our setup with both the modified and unmodified versions of omap-mcbsp.c, and in both cases TX works great and RX returns only silence (0x00 samples). Any help would greatly be appreciated. Thanks in advance. -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Question: Custom DAI driver for AM35xx using McBSP 2012-02-29 17:27 ` CF Adad @ 2012-03-01 17:13 ` CF Adad 2012-03-01 23:16 ` Ethernet problems on AM3517, possible regression? CF Adad 0 siblings, 1 reply; 9+ messages in thread From: CF Adad @ 2012-03-01 17:13 UTC (permalink / raw) To: linux-omap@vger.kernel.org We have resolved our issue with the help of PaulM at TI. The driver does work, the trouble was with the way the data was being masked in the buffer. We posted a detailed explanation on the E2E forum (link above) that you may review if interested. Thanks. -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 9+ messages in thread
* Ethernet problems on AM3517, possible regression? 2012-03-01 17:13 ` CF Adad @ 2012-03-01 23:16 ` CF Adad 2012-03-04 9:41 ` Igor Grinberg 2012-03-05 17:32 ` CF Adad 0 siblings, 2 replies; 9+ messages in thread From: CF Adad @ 2012-03-01 23:16 UTC (permalink / raw) To: linux-omap@vger.kernel.org We have both a CompuLab CM-T3517 and a Technexion TAM-3517 at the shop. Both boards provide dual Ethernet support in an identical fashion. One port uses the onboard EMAC tied to an SMSC LAN87xx series PHY. The other is the old trusty SMSC LAN911X hooked up to the GPMC. Both boards support both interfaces when loaded with their respective TI PSP-based images. These unfortunately date clear back to 2.6.37 or even 2.6.32 however. When upgrading to the 3.x series linux-omap kernel, we noticed we could get one or the other of these to work, _but not both simultaneously_. If both are enabled in code, neither work. Even when we can get one or the other working, we seem to be having some problems with autonegotiation and MAC addressing. MAC addresses on the SMSC are still random. On the EMAC port, as you can see from our code below, we have put a patch in that is letting us establish a fixed MAC address. However, I'm not sure this is a proper method to use at this point. We suspect issues are known to exist with the Ethernet ports as the CM-T3517 has mainlined Linux support, and its latest board file does not show any configuration for either Ethernet interface. Support from the previous kernel versions has apparently been removed, despite patches being applied to it as recently as mid-last year: http://lists.infradead.org/pipermail/linux-arm-kernel/2011-May/050430.html We also suspect this is being caused by an address conflict of some sort between the two ports. We are using a linux-omap kernel, version 3.2.0-rc6 that is a month or two old now. We've been monitoring this list, and have noted that some changes have been checked in for SMSC, but have not been able to update our kernel source as we were in the midst of a heavy debugging exercise that ended late last evening. We plan to migrate to the latest HEAD soon. Neverthelss, we've not seen any of these board files update. So, we're assuming there are still known issues here. I have attached the relevant sections of the board file we've created for the TAM-3517 (the one we've played with the most) below. It is based off the older board files from the TI PSP and various configurations we have seen in similar hardware board files (overo, am3517_evm, cm-t3517, etc.) If you note the configurable defines at the top, we've tied various combinations of code with no success to date. Would you folks please take a look? Any help would be appreciated. Thanks! ----------------------------------------------------------------------------------------------------------------- __NOTES:__ ***When we run with just the SMSC enabled, the device works: ... [ 1.119415] smsc911x: Driver version 2008-10-21 [ 1.126739] smsc911x-mdio: probed [ 1.130554] smsc911x smsc911x: eth0: attached PHY driver [SMSC LAN8700] (mii_bus:phy_addr=ffffffff:01, irq=-1) [ 1.142456] smsc911x smsc911x: eth0: MAC Address: d6:b4:7d:2c:03:40 ... root@board:~# ifdown eth0 root@board:~# ifup eth0 [ 187.145019] smsc911x smsc911x: eth0: SMSC911x/921x identified at 0xd086e000, IRQ: 313 ... (*NOTE: the MAC address is random!) ***When we run with just the EMAC enabled, the device works: ... [ 1.184112] davinci_mdio davinci_mdio.0: davinci mdio revision 1.5 [ 1.190612] davinci_mdio davinci_mdio.0: detected phy mask fffffffe [ 1.197998] davinci_mdio.0: probed [ 1.201690] davinci_mdio davinci_mdio.0: phy[0]: device 0:00, driver SMSC LAN8710/LAN8720 ... [ 213.613555] davinci_mdio davinci_mdio.0: resetting idled controller [ 213.621704] net eth0: attached PHY driver [SMSC LAN8710/LAN8720] (mii_bus:phy_addr=0:00, id=7c0f1) [ 215.621917] PHY: 0:00 - Link is Up - 100/Full ... *** When we run with BOTH enabled, they show in boot but neither works: [ 1.135864] smsc911x: Driver version 2008-10-21 [ 1.143249] smsc911x-mdio: probed [ 1.147064] smsc911x smsc911x: eth0: attached PHY driver [SMSC LAN8700] (mii_bus:phy_addr=ffffffff:01, irq=-1) [ 1.158966] smsc911x smsc911x: eth0: MAC Address: 7e:92:21:13:be:ec [ 1.207580] davinci_mdio davinci_mdio.0: davinci mdio revision 1.5 [ 1.214080] davinci_mdio davinci_mdio.0: detected phy mask fffffffe [ 1.221405] davinci_mdio.0: probed [ 1.225097] davinci_mdio davinci_mdio.0: phy[0]: device 0:00, driver SMSC LAN8710/LAN8720 ... root@board:~# ifup eth0 ifconfig: SIOCSIFFLAGS: Input/output error ifconfig: SIOCSIFFLAGS: Input/output error ... root@board:~# ifup eth1 [ 1034.624603] net eth1: PHY already attached [ 1034.628936] net eth1: could not connect to phy ffffffff:01 ----------------------------------------------------------------------------------------------------------------- /* * linux/arch/arm/mach-omap2/board-tam3517.c * * Copyright (C) 2011 * Author: Technexion + others * * Based on mach-omap2/board-tam3517.c from Technexion BSP release * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation version 2. * * This program is distributed "as is" WITHOUT ANY WARRANTY of any kind, * whether express or implied; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. */ #include <linux/kernel.h> #include <linux/init.h> #include <linux/clk.h> #include <linux/platform_device.h> #include <linux/delay.h> #include <linux/gpio.h> #include <linux/mtd/mtd.h> #include <linux/mtd/nand.h> #include <linux/mtd/partitions.h> #include <linux/can/platform/ti_hecc.h> #include <linux/mmc/host.h> #include <linux/regulator/machine.h> #include <linux/regulator/fixed.h> #include <mach/hardware.h> #include <asm/mach-types.h> #include <asm/mach/arch.h> #include <asm/mach/map.h> #include <plat/board.h> #include "common.h" #include <plat/usb.h> #include <plat/nand.h> #include <plat/gpmc.h> #include <mach/am35xx.h> #include "mux.h" #include "control.h" #include "hsmmc.h" /* custom settings */ #define ENABLE_EMAC_ETH 1 // this messes with the SMSC right now #define USE_ALT__EMAC_ETH 0 #define ENABLE_SMSC_ETH 1 // this messes with the EMAC right now #define USE_ALT__SMSC_ETH 0 {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} {{{{{{{{{{{{{{{{{{{{{{{{{{{ SNIP }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} /**************************************************************************** * * SMSC LAN * ****************************************************************************/ #if ENABLE_SMSC_ETH && ( defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE) ) #include <linux/smsc911x.h> #include <plat/gpmc-smsc911x.h> #define SMSC911X_GPIO_IRQ 153 #define SMSC911X_GPIO_RESET 142 #define SMSC911X_GPIO_CS 5 #if USE_ALT__SMSC_ETH // gpmc-smsc911x style static struct omap_smsc911x_platform_data tam3517_smsc911x_cfg = { .id = 0, .cs = SMSC911X_GPIO_CS, .gpio_irq = SMSC911X_GPIO_IRQ, .gpio_reset = -EINVAL, .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS, }; static void __init tam3517_init_smsc911x(void) { gpmc_smsc911x_init(&tam3517_smsc911x_cfg); } #else // use older style static struct resource tam3517_smsc911x_resources[] = { { .name = "smsc911x-memory", .flags = IORESOURCE_MEM, }, { .start = OMAP_GPIO_IRQ(SMSC911X_GPIO_IRQ), .end = OMAP_GPIO_IRQ(SMSC911X_GPIO_IRQ), .flags = (IORESOURCE_IRQ | IRQF_TRIGGER_LOW), }, }; static struct smsc911x_platform_config smsc911x_config = { .phy_interface = PHY_INTERFACE_MODE_MII, .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW, .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN, .flags = SMSC911X_USE_16BIT | SMSC911X_SAVE_MAC_ADDRESS, }; static struct platform_device tam3517_smsc911x_device = { .name = "smsc911x", .id = -1, .num_resources = ARRAY_SIZE(tam3517_smsc911x_resources), .resource = tam3517_smsc911x_resources, .dev = { .platform_data = &smsc911x_config, }, }; static void __init tam3517_init_smsc911x(void) { unsigned long cs_mem_base; if (gpmc_cs_request(SMSC911X_GPIO_CS, SZ_16M, &cs_mem_base) < 0) { printk(KERN_ERR "Failed request for GPMC mem for smsc911x\n"); return; } tam3517_smsc911x_resources[0].start = cs_mem_base + 0x0; tam3517_smsc911x_resources[0].end = cs_mem_base + 0xFF; if ((gpio_request(SMSC911X_GPIO_IRQ, "smsc911x irq") == 0) && (gpio_direction_input(SMSC911X_GPIO_IRQ) == 0)) { gpio_export(SMSC911X_GPIO_IRQ, 0); } else { printk(KERN_ERR "could not obtain gpio for SMSC911X IRQ\n"); return; } omap_mux_init_gpio(SMSC911X_GPIO_IRQ, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE4); gpio_direction_input(SMSC911X_GPIO_IRQ); // next 2 lines redundant? tam3517_smsc911x_resources[1].start = OMAP_GPIO_IRQ(SMSC911X_GPIO_IRQ); tam3517_smsc911x_resources[1].end = OMAP_GPIO_IRQ(SMSC911X_GPIO_IRQ); omap_mux_init_gpio(SMSC911X_GPIO_RESET, OMAP_PIN_INPUT_PULLUP|OMAP_MUX_MODE4); if (gpio_request(SMSC911X_GPIO_RESET, "smsc911x reset") < 0) { printk(KERN_ERR "can't get smsc911x reset GPIO\n"); return; } gpio_direction_output(SMSC911X_GPIO_RESET, 0); mdelay(1); gpio_direction_output(SMSC911X_GPIO_RESET, 1); } #endif // USE_ALT__SMSC_ETH #else static inline void __init tam3517_init_smsc911x(void) { return; } #endif /**************************************************************************** * * EMAC LAN * ****************************************************************************/ #if ENABLE_EMAC_ETH #include <linux/davinci_emac.h> #define AM35XX_EVM_MDIO_FREQUENCY (1000000) #if USE_ALT__EMAC_ETH // Use new standalone EMAC code for generic AM35xx? #include "am35xx-emac.h" #else // Use original Davinci EMAC code static struct resource tam3517_mdio_resources[] = { { .start = AM35XX_IPSS_EMAC_BASE + AM35XX_EMAC_MDIO_OFFSET, .end = AM35XX_IPSS_EMAC_BASE + AM35XX_EMAC_MDIO_OFFSET + SZ_4K - 1, .flags = IORESOURCE_MEM, }, }; static struct mdio_platform_data tam3517_mdio_pdata = { .bus_freq = AM35XX_EVM_MDIO_FREQUENCY, }; static struct platform_device tam3517_mdio_device = { .name = "davinci_mdio", .id = 0, .num_resources = ARRAY_SIZE(tam3517_mdio_resources), .resource = tam3517_mdio_resources, .dev.platform_data = &tam3517_mdio_pdata, }; static struct emac_platform_data tam3517_emac_pdata = { .rmii_en = 1, }; static struct resource tam3517_emac_resources[] = { { .start = AM35XX_IPSS_EMAC_BASE, .end = AM35XX_IPSS_EMAC_BASE + 0x2FFFF, .flags = IORESOURCE_MEM, }, { .start = INT_35XX_EMAC_C0_RXTHRESH_IRQ, .end = INT_35XX_EMAC_C0_RXTHRESH_IRQ, .flags = IORESOURCE_IRQ, }, { .start = INT_35XX_EMAC_C0_RX_PULSE_IRQ, .end = INT_35XX_EMAC_C0_RX_PULSE_IRQ, .flags = IORESOURCE_IRQ, }, { .start = INT_35XX_EMAC_C0_TX_PULSE_IRQ, .end = INT_35XX_EMAC_C0_TX_PULSE_IRQ, .flags = IORESOURCE_IRQ, }, { .start = INT_35XX_EMAC_C0_MISC_PULSE_IRQ, .end = INT_35XX_EMAC_C0_MISC_PULSE_IRQ, .flags = IORESOURCE_IRQ, }, }; static struct platform_device tam3517_emac_device = { .name = "davinci_emac", .id = -1, .num_resources = ARRAY_SIZE(tam3517_emac_resources), .resource = tam3517_emac_resources, }; static void tam3517_enable_emac_int(void) { u32 regval; regval = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR); regval = (regval | AM35XX_CPGMAC_C0_RX_PULSE_CLR | AM35XX_CPGMAC_C0_TX_PULSE_CLR | AM35XX_CPGMAC_C0_MISC_PULSE_CLR | AM35XX_CPGMAC_C0_RX_THRESH_CLR); omap_ctrl_writel(regval, AM35XX_CONTROL_LVL_INTR_CLEAR); regval = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR); } static void tam3517_disable_emac_int(void) { u32 regval; regval = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR); regval = (regval | AM35XX_CPGMAC_C0_RX_PULSE_CLR | AM35XX_CPGMAC_C0_TX_PULSE_CLR); omap_ctrl_writel(regval, AM35XX_CONTROL_LVL_INTR_CLEAR); regval = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR); } static void tam3517_emac_ethernet_init(void) { u32 regval, mac_lo, mac_hi; mac_lo = omap_ctrl_readl(AM35XX_CONTROL_FUSE_EMAC_LSB); mac_hi = omap_ctrl_readl(AM35XX_CONTROL_FUSE_EMAC_MSB); tam3517_emac_pdata.mac_addr[0] = (u_int8_t)((mac_hi & 0xFF0000) >> 16); tam3517_emac_pdata.mac_addr[1] = (u_int8_t)((mac_hi & 0xFF00) >> 8); tam3517_emac_pdata.mac_addr[2] = (u_int8_t)((mac_hi & 0xFF) >> 0); tam3517_emac_pdata.mac_addr[3] = (u_int8_t)((mac_lo & 0xFF0000) >> 16); tam3517_emac_pdata.mac_addr[4] = (u_int8_t)((mac_lo & 0xFF00) >> 8); tam3517_emac_pdata.mac_addr[5] = (u_int8_t)((mac_lo & 0xFF) >> 0); tam3517_emac_pdata.ctrl_reg_offset = AM35XX_EMAC_CNTRL_OFFSET; tam3517_emac_pdata.ctrl_mod_reg_offset = AM35XX_EMAC_CNTRL_MOD_OFFSET; tam3517_emac_pdata.ctrl_ram_offset = AM35XX_EMAC_CNTRL_RAM_OFFSET; tam3517_emac_pdata.ctrl_ram_size = AM35XX_EMAC_CNTRL_RAM_SIZE; tam3517_emac_pdata.version = EMAC_VERSION_2; tam3517_emac_pdata.hw_ram_addr = AM35XX_EMAC_HW_RAM_ADDR; tam3517_emac_pdata.interrupt_enable = tam3517_enable_emac_int; tam3517_emac_pdata.interrupt_disable = tam3517_disable_emac_int; tam3517_emac_device.dev.platform_data = &tam3517_emac_pdata; /* taken care of with platform_add_devices() below platform_device_register(&tam3517_emac_device); platform_device_register(&tam3517_mdio_device); */ clk_add_alias(NULL, dev_name(&tam3517_mdio_device.dev), NULL, &tam3517_emac_device.dev); regval = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET); regval = regval & (~(AM35XX_CPGMACSS_SW_RST)); omap_ctrl_writel(regval, AM35XX_CONTROL_IP_SW_RESET); regval = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET); } #endif // USE_ALT__EMAC_ETH #endif // ENABLE_EMAC_ETH {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} {{{{{{{{{{{{{{{{{{{{{{{{{{{ SNIP }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} /* --------------------------------------------------------- */ static struct omap_board_config_kernel tam3517_config[] = {}; /* --------------------------------------------------------- */ static struct platform_device *tam3517_devices[] __initdata = { #if ENABLE_SMSC_ETH && !(USE_ALT__SMSC_ETH) && ( defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE) ) &tam3517_smsc911x_device, #endif #if 0 && ( defined(CONFIG_CAN_TI_HECC) || defined(CONFIG_CAN_TI_HECC_MODULE) ) &tam3517_hecc_device, #endif &tam3517_dss_device, #if ENABLE_EMAC_ETH && !(USE_ALT__EMAC_ETH) &tam3517_mdio_device, &tam3517_emac_device, #endif #if 0 && ( defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) ) &tam3517_keys_gpio, #endif }; /* ------------------------------------------------------------------- */ static void __init tam3517_init(void) { platform_add_devices(tam3517_devices, ARRAY_SIZE(tam3517_devices)); omap_board_config = tam3517_config; omap_board_config_size = ARRAY_SIZE(tam3517_config); omap3_mux_init(tam3517_mux, OMAP_PACKAGE_CBC); omap_serial_init(); tam3517_i2c_init(); omap2_hsmmc_init(mmc); tam3517_usb_init(); tam3517_nand_init(); /*Ethernet: SMSC911x */ #if ENABLE_SMSC_ETH tam3517_init_smsc911x(); #endif /*Ethernet: DaVinci EMAC */ #if ENABLE_EMAC_ETH #if USE_ALT__EMAC_ETH am35xx_ethernet_init(AM35XX_EVM_MDIO_FREQUENCY, 1); #else tam3517_emac_ethernet_init(); #endif // USE_ALT__EMAC_ETH #endif // ENABLE_EMAC_ETH } MACHINE_START(TAM3517, "Technexion TAM3517") .atag_offset = 0x100, .reserve = omap_reserve, .map_io = omap3_map_io, .init_early = am35xx_init_early, .init_irq = omap3_init_irq, .handle_irq = omap3_intc_handle_irq, .init_machine = tam3517_init, .timer = &omap3_timer, MACHINE_END -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Ethernet problems on AM3517, possible regression? 2012-03-01 23:16 ` Ethernet problems on AM3517, possible regression? CF Adad @ 2012-03-04 9:41 ` Igor Grinberg 2012-03-05 11:38 ` Igor Grinberg 2012-03-05 17:32 ` CF Adad 1 sibling, 1 reply; 9+ messages in thread From: Igor Grinberg @ 2012-03-04 9:41 UTC (permalink / raw) To: CF Adad; +Cc: linux-omap@vger.kernel.org, Tony Lindgren Hi, On 03/02/12 01:16, CF Adad wrote: > We have both a CompuLab CM-T3517 and a Technexion TAM-3517 at the shop. Both boards provide dual Ethernet support in an identical fashion. One port uses the onboard EMAC tied to an SMSC LAN87xx series PHY. The other is the old trusty SMSC LAN911X hooked up to the GPMC. > > Both boards support both interfaces when loaded with their respective TI PSP-based images. These unfortunately date clear back to 2.6.37 or even 2.6.32 however. When upgrading to the 3.x series linux-omap kernel, we noticed we could get one or the other of these to work, _but not both simultaneously_. If both are enabled in code, neither work. > > Even when we can get one or the other working, we seem to be having some problems with autonegotiation and MAC addressing. MAC addresses on the SMSC are still random. On the EMAC port, as you can see from our code below, we have put a patch in that is letting us establish a fixed MAC address. However, I'm not sure this is a proper method to use at this point. > > We suspect issues are known to exist with the Ethernet ports as the CM-T3517 has mainlined Linux support, and its latest board file does not show any configuration for either Ethernet interface. Support from the previous kernel versions has apparently been removed, despite patches being applied to it as recently as mid-last year: http://lists.infradead.org/pipermail/linux-arm-kernel/2011-May/050430.html > > We also suspect this is being caused by an address conflict of some sort between the two ports. We are using a linux-omap kernel, version 3.2.0-rc6 that is a month or two old now. We've been monitoring this list, and have noted that some changes have been checked in for SMSC, but have not been able to update our kernel source as we were in the midst of a heavy debugging exercise that ended late last evening. We plan to migrate to the latest HEAD soon. Neverthelss, we've not seen any of these board files update. So, we're assuming there are still known issues here. > > I have attached the relevant sections of the board file we've created > for the TAM-3517 (the one we've played with the most) below. It is based off the > older board files from the TI PSP and various configurations we have seen in similar hardware > board files (overo, am3517_evm, cm-t3517, etc.) If you note the > configurable defines at the top, we've tied various combinations of code > with no success to date. > > > Would you folks please take a look? Any help would be appreciated. Thanks! The below two patches are needed to make the AM3517 EMAC work on CM-T3517: http://www.spinics.net/lists/linux-omap/msg65642.html http://www.spinics.net/lists/linux-omap/msg65643.html Hopefully, Tony will be kind enough to apply those for 3.4 -- Regards, Igor. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Ethernet problems on AM3517, possible regression? 2012-03-04 9:41 ` Igor Grinberg @ 2012-03-05 11:38 ` Igor Grinberg 0 siblings, 0 replies; 9+ messages in thread From: Igor Grinberg @ 2012-03-05 11:38 UTC (permalink / raw) To: CF Adad; +Cc: linux-omap@vger.kernel.org, Tony Lindgren, Paul Walmsley On 03/04/12 11:41, Igor Grinberg wrote: > Hi, > > On 03/02/12 01:16, CF Adad wrote: >> We have both a CompuLab CM-T3517 and a Technexion TAM-3517 at the shop. Both boards provide dual Ethernet support in an identical fashion. One port uses the onboard EMAC tied to an SMSC LAN87xx series PHY. The other is the old trusty SMSC LAN911X hooked up to the GPMC. >> >> Both boards support both interfaces when loaded with their respective TI PSP-based images. These unfortunately date clear back to 2.6.37 or even 2.6.32 however. When upgrading to the 3.x series linux-omap kernel, we noticed we could get one or the other of these to work, _but not both simultaneously_. If both are enabled in code, neither work. >> >> Even when we can get one or the other working, we seem to be having some problems with autonegotiation and MAC addressing. MAC addresses on the SMSC are still random. On the EMAC port, as you can see from our code below, we have put a patch in that is letting us establish a fixed MAC address. However, I'm not sure this is a proper method to use at this point. >> >> We suspect issues are known to exist with the Ethernet ports as the CM-T3517 has mainlined Linux support, and its latest board file does not show any configuration for either Ethernet interface. Support from the previous kernel versions has apparently been removed, despite patches being applied to it as recently as mid-last year: http://lists.infradead.org/pipermail/linux-arm-kernel/2011-May/050430.html >> >> We also suspect this is being caused by an address conflict of some sort between the two ports. We are using a linux-omap kernel, version 3.2.0-rc6 that is a month or two old now. We've been monitoring this list, and have noted that some changes have been checked in for SMSC, but have not been able to update our kernel source as we were in the midst of a heavy debugging exercise that ended late last evening. We plan to migrate to the latest HEAD soon. Neverthelss, we've not seen any of these board files update. So, we're assuming there are still known issues here. >> >> I have attached the relevant sections of the board file we've created >> for the TAM-3517 (the one we've played with the most) below. It is based off the >> older board files from the TI PSP and various configurations we have seen in similar hardware >> board files (overo, am3517_evm, cm-t3517, etc.) If you note the >> configurable defines at the top, we've tied various combinations of code >> with no success to date. >> >> >> Would you folks please take a look? Any help would be appreciated. Thanks! > > The below two patches are needed to make the AM3517 EMAC work on CM-T3517: > > http://www.spinics.net/lists/linux-omap/msg65642.html > http://www.spinics.net/lists/linux-omap/msg65643.html > > Hopefully, Tony will be kind enough to apply those for 3.4 Also, this one is needed for EMAC to function on any OMAP board: http://www.spinics.net/lists/linux-omap/msg62161.html It looks from the thread, that it has been already taken by Paul, so hopefully, it will be in 3.4 -- Regards, Igor. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Ethernet problems on AM3517, possible regression? 2012-03-01 23:16 ` Ethernet problems on AM3517, possible regression? CF Adad 2012-03-04 9:41 ` Igor Grinberg @ 2012-03-05 17:32 ` CF Adad 2012-03-06 9:16 ` Igor Grinberg 1 sibling, 1 reply; 9+ messages in thread From: CF Adad @ 2012-03-05 17:32 UTC (permalink / raw) To: linux-omap@vger.kernel.org ****** Sorry this is almost certainly going to the wrong place for this post to land. I'm still trying to sort out how to properly use this list. I have tried subscribing, but that tends to flood my inbox with everything going on here. That's great, but timewise I haven't been able to follow it closely enough to keep it sorted at the moment. Is there a way to simply subscribe to certain threads, like those one posts or replies to? Once I unsubscribed from the list, I started receiving no messages - even responses to questions I ask, etc. :-( Thanks. ****** Hi Igor, Thanks for your reply! So are both ports working on the CM-T3517 simultaneously now? Looking at the latest board file for the CM-T3517 (arch/arm/mach-omap2/board-cm-t3517.c), I don't see either the SMSC or the EMAC ports being initialized. Has that initialization code been moved somewhere else in the kernel? Regarding the patches: I had actually seen those (in the previous "version #2" I believe), and applied them to our kernel. If you take a look at my board file below, you'll notice I defined a "USE_ALT__EMAC_ETH" definition that causes the separate EMAC file (created by those patches) to be used. I've tried both the old and the new (separate file) way of doing this. Our EMAC does work fine, as does our SMSC, except our SMSC does not store a MAC address. They just do not work together. One or the other must be disabled (commented out of the code) or neither work. It appears to me that the problem with running both is the mdio id setting. Perhaps they're both demanding the same slot or something? Thanks again for your reply. Please let me if I'm looking in the wrong place for any of this or have this mixed up. ----- Original Message ----- From: CF Adad <cfadad@rocketmail.com> To: "linux-omap@vger.kernel.org" <linux-omap@vger.kernel.org> Cc: Sent: Thursday, March 1, 2012 6:16 PM Subject: Ethernet problems on AM3517, possible regression? We have both a CompuLab CM-T3517 and a Technexion TAM-3517 at the shop. Both boards provide dual Ethernet support in an identical fashion. One port uses the onboard EMAC tied to an SMSC LAN87xx series PHY. The other is the old trusty SMSC LAN911X hooked up to the GPMC. Both boards support both interfaces when loaded with their respective TI PSP-based images. These unfortunately date clear back to 2.6.37 or even 2.6.32 however. When upgrading to the 3.x series linux-omap kernel, we noticed we could get one or the other of these to work, _but not both simultaneously_. If both are enabled in code, neither work. Even when we can get one or the other working, we seem to be having some problems with autonegotiation and MAC addressing. MAC addresses on the SMSC are still random. On the EMAC port, as you can see from our code below, we have put a patch in that is letting us establish a fixed MAC address. However, I'm not sure this is a proper method to use at this point. We suspect issues are known to exist with the Ethernet ports as the CM-T3517 has mainlined Linux support, and its latest board file does not show any configuration for either Ethernet interface. Support from the previous kernel versions has apparently been removed, despite patches being applied to it as recently as mid-last year: http://lists.infradead.org/pipermail/linux-arm-kernel/2011-May/050430.html We also suspect this is being caused by an address conflict of some sort between the two ports. We are using a linux-omap kernel, version 3.2.0-rc6 that is a month or two old now. We've been monitoring this list, and have noted that some changes have been checked in for SMSC, but have not been able to update our kernel source as we were in the midst of a heavy debugging exercise that ended late last evening. We plan to migrate to the latest HEAD soon. Neverthelss, we've not seen any of these board files update. So, we're assuming there are still known issues here. I have attached the relevant sections of the board file we've created for the TAM-3517 (the one we've played with the most) below. It is based off the older board files from the TI PSP and various configurations we have seen in similar hardware board files (overo, am3517_evm, cm-t3517, etc.) If you note the configurable defines at the top, we've tied various combinations of code with no success to date. Would you folks please take a look? Any help would be appreciated. Thanks! ----------------------------------------------------------------------------------------------------------------- __NOTES:__ ***When we run with just the SMSC enabled, the device works: ... [ 1.119415] smsc911x: Driver version 2008-10-21 [ 1.126739] smsc911x-mdio: probed [ 1.130554] smsc911x smsc911x: eth0: attached PHY driver [SMSC LAN8700] (mii_bus:phy_addr=ffffffff:01, irq=-1) [ 1.142456] smsc911x smsc911x: eth0: MAC Address: d6:b4:7d:2c:03:40 ... root@board:~# ifdown eth0 root@board:~# ifup eth0 [ 187.145019] smsc911x smsc911x: eth0: SMSC911x/921x identified at 0xd086e000, IRQ: 313 ... (*NOTE: the MAC address is random!) ***When we run with just the EMAC enabled, the device works: ... [ 1.184112] davinci_mdio davinci_mdio.0: davinci mdio revision 1.5 [ 1.190612] davinci_mdio davinci_mdio.0: detected phy mask fffffffe [ 1.197998] davinci_mdio.0: probed [ 1.201690] davinci_mdio davinci_mdio.0: phy[0]: device 0:00, driver SMSC LAN8710/LAN8720 ... [ 213.613555] davinci_mdio davinci_mdio.0: resetting idled controller [ 213.621704] net eth0: attached PHY driver [SMSC LAN8710/LAN8720] (mii_bus:phy_addr=0:00, id=7c0f1) [ 215.621917] PHY: 0:00 - Link is Up - 100/Full ... *** When we run with BOTH enabled, they show in boot but neither works: [ 1.135864] smsc911x: Driver version 2008-10-21 [ 1.143249] smsc911x-mdio: probed [ 1.147064] smsc911x smsc911x: eth0: attached PHY driver [SMSC LAN8700] (mii_bus:phy_addr=ffffffff:01, irq=-1) [ 1.158966] smsc911x smsc911x: eth0: MAC Address: 7e:92:21:13:be:ec [ 1.207580] davinci_mdio davinci_mdio.0: davinci mdio revision 1.5 [ 1.214080] davinci_mdio davinci_mdio.0: detected phy mask fffffffe [ 1.221405] davinci_mdio.0: probed [ 1.225097] davinci_mdio davinci_mdio.0: phy[0]: device 0:00, driver SMSC LAN8710/LAN8720 ... root@board:~# ifup eth0 ifconfig: SIOCSIFFLAGS: Input/output error ifconfig: SIOCSIFFLAGS: Input/output error ... root@board:~# ifup eth1 [ 1034.624603] net eth1: PHY already attached [ 1034.628936] net eth1: could not connect to phy ffffffff:01 ----------------------------------------------------------------------------------------------------------------- /* * linux/arch/arm/mach-omap2/board-tam3517.c * * Copyright (C) 2011 * Author: Technexion + others * * Based on mach-omap2/board-tam3517.c from Technexion BSP release * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation version 2. * * This program is distributed "as is" WITHOUT ANY WARRANTY of any kind, * whether express or implied; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. */ #include <linux/kernel.h> #include <linux/init.h> #include <linux/clk.h> #include <linux/platform_device.h> #include <linux/delay.h> #include <linux/gpio.h> #include <linux/mtd/mtd.h> #include <linux/mtd/nand.h> #include <linux/mtd/partitions.h> #include <linux/can/platform/ti_hecc.h> #include <linux/mmc/host.h> #include <linux/regulator/machine.h> #include <linux/regulator/fixed.h> #include <mach/hardware.h> #include <asm/mach-types.h> #include <asm/mach/arch.h> #include <asm/mach/map.h> #include <plat/board.h> #include "common.h" #include <plat/usb.h> #include <plat/nand.h> #include <plat/gpmc.h> #include <mach/am35xx.h> #include "mux.h" #include "control.h" #include "hsmmc.h" /* custom settings */ #define ENABLE_EMAC_ETH 1 // this messes with the SMSC right now #define USE_ALT__EMAC_ETH 0 #define ENABLE_SMSC_ETH 1 // this messes with the EMAC right now #define USE_ALT__SMSC_ETH 0 {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} {{{{{{{{{{{{{{{{{{{{{{{{{{{ SNIP }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} /**************************************************************************** * * SMSC LAN * ****************************************************************************/ #if ENABLE_SMSC_ETH && ( defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE) ) #include <linux/smsc911x.h> #include <plat/gpmc-smsc911x.h> #define SMSC911X_GPIO_IRQ 153 #define SMSC911X_GPIO_RESET 142 #define SMSC911X_GPIO_CS 5 #if USE_ALT__SMSC_ETH // gpmc-smsc911x style static struct omap_smsc911x_platform_data tam3517_smsc911x_cfg = { .id = 0, .cs = SMSC911X_GPIO_CS, .gpio_irq = SMSC911X_GPIO_IRQ, .gpio_reset = -EINVAL, .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS, }; static void __init tam3517_init_smsc911x(void) { gpmc_smsc911x_init(&tam3517_smsc911x_cfg); } #else // use older style static struct resource tam3517_smsc911x_resources[] = { { .name = "smsc911x-memory", .flags = IORESOURCE_MEM, }, { .start = OMAP_GPIO_IRQ(SMSC911X_GPIO_IRQ), .end = OMAP_GPIO_IRQ(SMSC911X_GPIO_IRQ), .flags = (IORESOURCE_IRQ | IRQF_TRIGGER_LOW), }, }; static struct smsc911x_platform_config smsc911x_config = { .phy_interface = PHY_INTERFACE_MODE_MII, .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW, .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN, .flags = SMSC911X_USE_16BIT | SMSC911X_SAVE_MAC_ADDRESS, }; static struct platform_device tam3517_smsc911x_device = { .name = "smsc911x", .id = -1, .num_resources = ARRAY_SIZE(tam3517_smsc911x_resources), .resource = tam3517_smsc911x_resources, .dev = { .platform_data = &smsc911x_config, }, }; static void __init tam3517_init_smsc911x(void) { unsigned long cs_mem_base; if (gpmc_cs_request(SMSC911X_GPIO_CS, SZ_16M, &cs_mem_base) < 0) { printk(KERN_ERR "Failed request for GPMC mem for smsc911x\n"); return; } tam3517_smsc911x_resources[0].start = cs_mem_base + 0x0; tam3517_smsc911x_resources[0].end = cs_mem_base + 0xFF; if ((gpio_request(SMSC911X_GPIO_IRQ, "smsc911x irq") == 0) && (gpio_direction_input(SMSC911X_GPIO_IRQ) == 0)) { gpio_export(SMSC911X_GPIO_IRQ, 0); } else { printk(KERN_ERR "could not obtain gpio for SMSC911X IRQ\n"); return; } omap_mux_init_gpio(SMSC911X_GPIO_IRQ, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE4); gpio_direction_input(SMSC911X_GPIO_IRQ); // next 2 lines redundant? tam3517_smsc911x_resources[1].start = OMAP_GPIO_IRQ(SMSC911X_GPIO_IRQ); tam3517_smsc911x_resources[1].end = OMAP_GPIO_IRQ(SMSC911X_GPIO_IRQ); omap_mux_init_gpio(SMSC911X_GPIO_RESET, OMAP_PIN_INPUT_PULLUP|OMAP_MUX_MODE4); if (gpio_request(SMSC911X_GPIO_RESET, "smsc911x reset") < 0) { printk(KERN_ERR "can't get smsc911x reset GPIO\n"); return; } gpio_direction_output(SMSC911X_GPIO_RESET, 0); mdelay(1); gpio_direction_output(SMSC911X_GPIO_RESET, 1); } #endif // USE_ALT__SMSC_ETH #else static inline void __init tam3517_init_smsc911x(void) { return; } #endif /**************************************************************************** * * EMAC LAN * ****************************************************************************/ #if ENABLE_EMAC_ETH #include <linux/davinci_emac.h> #define AM35XX_EVM_MDIO_FREQUENCY (1000000) #if USE_ALT__EMAC_ETH // Use new standalone EMAC code for generic AM35xx? #include "am35xx-emac.h" #else // Use original Davinci EMAC code static struct resource tam3517_mdio_resources[] = { { .start = AM35XX_IPSS_EMAC_BASE + AM35XX_EMAC_MDIO_OFFSET, .end = AM35XX_IPSS_EMAC_BASE + AM35XX_EMAC_MDIO_OFFSET + SZ_4K - 1, .flags = IORESOURCE_MEM, }, }; static struct mdio_platform_data tam3517_mdio_pdata = { .bus_freq = AM35XX_EVM_MDIO_FREQUENCY, }; static struct platform_device tam3517_mdio_device = { .name = "davinci_mdio", .id = 0, .num_resources = ARRAY_SIZE(tam3517_mdio_resources), .resource = tam3517_mdio_resources, .dev.platform_data = &tam3517_mdio_pdata, }; static struct emac_platform_data tam3517_emac_pdata = { .rmii_en = 1, }; static struct resource tam3517_emac_resources[] = { { .start = AM35XX_IPSS_EMAC_BASE, .end = AM35XX_IPSS_EMAC_BASE + 0x2FFFF, .flags = IORESOURCE_MEM, }, { .start = INT_35XX_EMAC_C0_RXTHRESH_IRQ, .end = INT_35XX_EMAC_C0_RXTHRESH_IRQ, .flags = IORESOURCE_IRQ, }, { .start = INT_35XX_EMAC_C0_RX_PULSE_IRQ, .end = INT_35XX_EMAC_C0_RX_PULSE_IRQ, .flags = IORESOURCE_IRQ, }, { .start = INT_35XX_EMAC_C0_TX_PULSE_IRQ, .end = INT_35XX_EMAC_C0_TX_PULSE_IRQ, .flags = IORESOURCE_IRQ, }, { .start = INT_35XX_EMAC_C0_MISC_PULSE_IRQ, .end = INT_35XX_EMAC_C0_MISC_PULSE_IRQ, .flags = IORESOURCE_IRQ, }, }; static struct platform_device tam3517_emac_device = { .name = "davinci_emac", .id = -1, .num_resources = ARRAY_SIZE(tam3517_emac_resources), .resource = tam3517_emac_resources, }; static void tam3517_enable_emac_int(void) { u32 regval; regval = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR); regval = (regval | AM35XX_CPGMAC_C0_RX_PULSE_CLR | AM35XX_CPGMAC_C0_TX_PULSE_CLR | AM35XX_CPGMAC_C0_MISC_PULSE_CLR | AM35XX_CPGMAC_C0_RX_THRESH_CLR); omap_ctrl_writel(regval, AM35XX_CONTROL_LVL_INTR_CLEAR); regval = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR); } static void tam3517_disable_emac_int(void) { u32 regval; regval = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR); regval = (regval | AM35XX_CPGMAC_C0_RX_PULSE_CLR | AM35XX_CPGMAC_C0_TX_PULSE_CLR); omap_ctrl_writel(regval, AM35XX_CONTROL_LVL_INTR_CLEAR); regval = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR); } static void tam3517_emac_ethernet_init(void) { u32 regval, mac_lo, mac_hi; mac_lo = omap_ctrl_readl(AM35XX_CONTROL_FUSE_EMAC_LSB); mac_hi = omap_ctrl_readl(AM35XX_CONTROL_FUSE_EMAC_MSB); tam3517_emac_pdata.mac_addr[0] = (u_int8_t)((mac_hi & 0xFF0000) >> 16); tam3517_emac_pdata.mac_addr[1] = (u_int8_t)((mac_hi & 0xFF00) >> 8); tam3517_emac_pdata.mac_addr[2] = (u_int8_t)((mac_hi & 0xFF) >> 0); tam3517_emac_pdata.mac_addr[3] = (u_int8_t)((mac_lo & 0xFF0000) >> 16); tam3517_emac_pdata.mac_addr[4] = (u_int8_t)((mac_lo & 0xFF00) >> 8); tam3517_emac_pdata.mac_addr[5] = (u_int8_t)((mac_lo & 0xFF) >> 0); tam3517_emac_pdata.ctrl_reg_offset = AM35XX_EMAC_CNTRL_OFFSET; tam3517_emac_pdata.ctrl_mod_reg_offset = AM35XX_EMAC_CNTRL_MOD_OFFSET; tam3517_emac_pdata.ctrl_ram_offset = AM35XX_EMAC_CNTRL_RAM_OFFSET; tam3517_emac_pdata.ctrl_ram_size = AM35XX_EMAC_CNTRL_RAM_SIZE; tam3517_emac_pdata.version = EMAC_VERSION_2; tam3517_emac_pdata.hw_ram_addr = AM35XX_EMAC_HW_RAM_ADDR; tam3517_emac_pdata.interrupt_enable = tam3517_enable_emac_int; tam3517_emac_pdata.interrupt_disable = tam3517_disable_emac_int; tam3517_emac_device.dev.platform_data = &tam3517_emac_pdata; /* taken care of with platform_add_devices() below platform_device_register(&tam3517_emac_device); platform_device_register(&tam3517_mdio_device); */ clk_add_alias(NULL, dev_name(&tam3517_mdio_device.dev), NULL, &tam3517_emac_device.dev); regval = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET); regval = regval & (~(AM35XX_CPGMACSS_SW_RST)); omap_ctrl_writel(regval, AM35XX_CONTROL_IP_SW_RESET); regval = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET); } #endif // USE_ALT__EMAC_ETH #endif // ENABLE_EMAC_ETH {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} {{{{{{{{{{{{{{{{{{{{{{{{{{{ SNIP }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} /* --------------------------------------------------------- */ static struct omap_board_config_kernel tam3517_config[] = {}; /* --------------------------------------------------------- */ static struct platform_device *tam3517_devices[] __initdata = { #if ENABLE_SMSC_ETH && !(USE_ALT__SMSC_ETH) && ( defined(CONFIG_SMSC911X) || defined(CONFIG_SMSC911X_MODULE) ) &tam3517_smsc911x_device, #endif #if 0 && ( defined(CONFIG_CAN_TI_HECC) || defined(CONFIG_CAN_TI_HECC_MODULE) ) &tam3517_hecc_device, #endif &tam3517_dss_device, #if ENABLE_EMAC_ETH && !(USE_ALT__EMAC_ETH) &tam3517_mdio_device, &tam3517_emac_device, #endif #if 0 && ( defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) ) &tam3517_keys_gpio, #endif }; /* ------------------------------------------------------------------- */ static void __init tam3517_init(void) { platform_add_devices(tam3517_devices, ARRAY_SIZE(tam3517_devices)); omap_board_config = tam3517_config; omap_board_config_size = ARRAY_SIZE(tam3517_config); omap3_mux_init(tam3517_mux, OMAP_PACKAGE_CBC); omap_serial_init(); tam3517_i2c_init(); omap2_hsmmc_init(mmc); tam3517_usb_init(); tam3517_nand_init(); /*Ethernet: SMSC911x */ #if ENABLE_SMSC_ETH tam3517_init_smsc911x(); #endif /*Ethernet: DaVinci EMAC */ #if ENABLE_EMAC_ETH #if USE_ALT__EMAC_ETH am35xx_ethernet_init(AM35XX_EVM_MDIO_FREQUENCY, 1); #else tam3517_emac_ethernet_init(); #endif // USE_ALT__EMAC_ETH #endif // ENABLE_EMAC_ETH } MACHINE_START(TAM3517, "Technexion TAM3517") .atag_offset = 0x100, .reserve = omap_reserve, .map_io = omap3_map_io, .init_early = am35xx_init_early, .init_irq = omap3_init_irq, .handle_irq = omap3_intc_handle_irq, .init_machine = tam3517_init, .timer = &omap3_timer, MACHINE_END -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Ethernet problems on AM3517, possible regression? 2012-03-05 17:32 ` CF Adad @ 2012-03-06 9:16 ` Igor Grinberg 2012-03-12 22:17 ` CF Adad 0 siblings, 1 reply; 9+ messages in thread From: Igor Grinberg @ 2012-03-06 9:16 UTC (permalink / raw) To: CF Adad; +Cc: linux-omap@vger.kernel.org Hi, On 03/05/12 19:32, CF Adad wrote: > Hi Igor, > > > Thanks for your reply! So are both ports working on the CM-T3517 simultaneously now? Well, you need to apply all the patches I've sent you. > Looking at the latest board file for the CM-T3517 (arch/arm/mach-omap2/board-cm-t3517.c), I don't see either the SMSC or the EMAC ports being initialized. Has that initialization code been moved somewhere else in the kernel? > Again, you need to apply the patches I've sent you. > Regarding the patches: I had actually seen those (in the previous "version #2" I believe), and applied them to our kernel. v3 is slightly different and you need the patch for the board file. You need also the patches I've sent you privately. > If you take a look at my board file below, you'll notice I defined a "USE_ALT__EMAC_ETH" definition that causes the separate EMAC file (created by those patches) to be used. I've tried both the old and the new (separate file) way of doing this. Our EMAC does work fine, as does our SMSC, except our SMSC does not store a MAC address. They just do not work together. One or the other must be disabled (commented out of the code) or neither work. The patch I've sent you solves exactly that... > > It appears to me that the problem with running both is the mdio id setting. Perhaps they're both demanding the same slot or something? Yes, there were several changes made to MDIO framework and how the whole thing is handled. -- Regards, Igor. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Ethernet problems on AM3517, possible regression? 2012-03-06 9:16 ` Igor Grinberg @ 2012-03-12 22:17 ` CF Adad 0 siblings, 0 replies; 9+ messages in thread From: CF Adad @ 2012-03-12 22:17 UTC (permalink / raw) To: Igor Grinberg; +Cc: linux-omap@vger.kernel.org Igor, THANKS SO MUCH FOR YOUR HELP! Your help has allowed us to fix the issue satisfactorally for now. ----------- For those interested, under our version of Linux (linux-omap-3.2-rc6), the two ports were essentially fighting for MDIO address id 0, and it also appeared the EMAC was trying to bind the SMSC's PHY. As we suspected, the "fix" was to force one of ports to stop trying to use address 0 and to tell the EMAC explicitly which PHY to use. We tried moving our kernel forward into the 3.3-rcX realm to make patching easier, but met a bunch of resistance from broken drivers we had working in the previous version. So, we went back. The changes we made were to move the EMAC to id '2', as shown below in the snip of our board file below. {{{SNIP}}} static struct platform_device b3517_mdio_device = { .name = "davinci_mdio", .id = 2, .num_resources = ARRAY_SIZE(b3517_mdio_resources), .resource = b3517_mdio_resources, .dev.platform_data = &b3517_mdio_pdata, }; static struct emac_platform_data b3517_emac_pdata = { .phy_id = "2:00", .rmii_en = 1, }; {{{SNIP}}} The operative argument here was the ".phy_id" directive Igor passed along. This forces the EMAC to grab a specific PHY, not just the first one sees, which for us always seemed to be the SMSC's. I'm not sure if it was necessary, but to keep all this in sync, I also altered the clock3xxx_data.c patch to setup "mdio.2" instead fo "mdio.0". + CLK("davinci_emac", NULL, &emac_ick, CK_AM35XX), + CLK("davinci_mdio.2", NULL, &emac_fck, CK_AM35XX), Anyway, things are working fine now as best we can tell. [ 1.052795] smsc911x: Driver version 2008-10-21 [ 1.059539] smsc911x-mdio: probed [ 1.063110] smsc911x smsc911x: eth0: attached PHY driver [Generic PHY] (mii_bus:phy_addr=ffffffff:01, irq=-1) [ 1.073852] smsc911x smsc911x: eth0: MAC Address: ??:??:??:??:??:?? [ 1.120544] davinci_mdio davinci_mdio.2: davinci mdio revision 1.5 [ 1.127014] davinci_mdio davinci_mdio.2: detected phy mask fffffffe [ 1.134124] davinci_mdio.2: probed [ 1.137786] davinci_mdio davinci_mdio.2: phy[0]: device 2:00, driver unknown We are anxious to move our kernel forward as soon as we reasonably can, as we've noted both the EMAC and SMSC have newer drivers similar boards are using. However, for us at the moment, the brokenness these changes bring to our effort isn't worth the time to correct it at the moment. THANKS AGAIN FOR ALL YOUR HELP! ---------------------------- Hi, On 03/05/12 19:32, CF Adad wrote: > Hi Igor, > > > Thanks for your reply! So are both ports working on the CM-T3517 simultaneously now? Well, you need to apply all the patches I've sent you. > Looking at the latest board file for the CM-T3517 (arch/arm/mach-omap2/board-cm-t3517.c), I don't see either the SMSC or the EMAC ports being initialized. Has that initialization code been moved somewhere else in the kernel? > Again, you need to apply the patches I've sent you. > Regarding the patches: I had actually seen those (in the previous "version #2" I believe), and applied them to our kernel. v3 is slightly different and you need the patch for the board file. You need also the patches I've sent you privately. > If you take a look at my board file below, you'll notice I defined a "USE_ALT__EMAC_ETH" definition that causes the separate EMAC file (created by those patches) to be used. I've tried both the old and the new (separate file) way of doing this. Our EMAC does work fine, as does our SMSC, except our SMSC does not store a MAC address. They just do not work together. One or the other must be disabled (commented out of the code) or neither work. The patch I've sent you solves exactly that... > > It appears to me that the problem with running both is the mdio id setting. Perhaps they're both demanding the same slot or something? Yes, there were several changes made to MDIO framework and how the whole thing is handled. -- Regards, Igor. -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2012-03-12 22:17 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-02-29 4:11 Question: Custom DAI driver for AM35xx using McBSP CF Adad 2012-02-29 17:27 ` CF Adad 2012-03-01 17:13 ` CF Adad 2012-03-01 23:16 ` Ethernet problems on AM3517, possible regression? CF Adad 2012-03-04 9:41 ` Igor Grinberg 2012-03-05 11:38 ` Igor Grinberg 2012-03-05 17:32 ` CF Adad 2012-03-06 9:16 ` Igor Grinberg 2012-03-12 22:17 ` CF Adad
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox