2009-04-07 16:12:55     Supporting two AD1836 codecs (on separate SPORT interfaces)

Document created by Aaronwu Employee on Aug 14, 2013Last modified by Aaronwu Employee on Aug 14, 2013
Version 2Show Document
  • View in full screen mode

2009-04-07 16:12:55     Supporting two AD1836 codecs (on separate SPORT interfaces)

Steve Strobel (UNITED STATES)

Message: 72359   

 

I am trying to figure out how to support two AD1836 codecs, treating them as separate sound "cards".  Each chip is interfaced to one of the BF537 SPORT channels.  Each one works when used independently (by setting up the driver to use its SPORT and SPI chip select).  I think that getting them to work at the same time should be as easy as setting up two peripherals that use the same driver, but the driver doesn't seem to be written to allow that, as the source says:

 

/* Only one AD1836 soundcard is supported */

static struct platform_device *device = NULL;

static struct ad1836_spi *ad1836_spi = NULL;

 

I would be interested in suggestions about how to "fix" the driver so it can support multiple instances, or maybe in an example of a sound driver that does.

 

Thanks,

 

Steve

 

P.S.  My actual situation is considerably more complicated.  I modified the AD1836 driver to make it work with the AD1938.  Attached to the same SPI chip select is an AD5204 soft-pot which is used for input level control;  I have to transfer data to both devices at the same time.  The basic problem, however, would be the same with the AD1836 driver that is in the distribution.

QuoteReplyEditDelete

 

 

2009-04-07 16:52:29     Re: Supporting two AD1836 codecs (on separate SPORT interfaces)

Mike Frysinger (UNITED STATES)

Message: 72362   

 

yes, the current driver only supports one instance ... in order to fix, all global state needs to be moved into private data and allocated on the fly in the snd_ad1836_probe() function.

QuoteReplyEditDelete

 

 

2009-04-07 16:54:02     Re: Supporting two AD1836 codecs (on separate SPORT interfaces)

Steve Strobel (UNITED STATES)

Message: 72363   

 

I tried a different approach to solving the problem of the AD1836 driver supporting only one "soundcard".  I copied the sound driver source file to a new name, gave the driver a new name (appending "-second") and tried to set up one driver for each codec chip.  I made both sound drivers use the same SPI driver, but with different chip selects.  I am getting error messages and a kernel panic on startup (log shown below).  Is this method even worth pursuing?  Any suggestions about what else I need to do to separate the drivers enough that they don't cause trouble on startup?  Thanks for any ideas.

 

Steve

 

 

 

From the arch/blackfin/mach-bf537/boards/target.c file:

 

static struct bfin5xx_spi_chip ad1938_spi_chip_info = {

    .bits_per_word = 24,                    // the AD1938 uses 24 rather than 16 bits like the AD1836

                                                     // the bit-banged SPI driver doesn't use .ctl_reg or .enable_dma

};

 

static struct bfin5xx_spi_chip ad5204_spi_chip_info = {

    .bits_per_word = 11,

};

 

static struct bfin5xx_spi_chip ad1938_second_spi_chip_info = {

    .bits_per_word = 24,                    // the AD1938 uses 24 rather than 16 bits like the AD1836

};

 

From the spi_board_info array:

 

    {

        .modalias = "ad1938-spi",      

        .max_speed_hz = 3125000,

        .bus_num = 2,                       // custom bit-banged SPI driver

        .chip_select = GPIO_PG3,

        .controller_data = &ad1938_spi_chip_info,

        .mode = SPI_MODE_0,

    },

 

    {

        .modalias = "ad5204-spi",      

        .max_speed_hz = 3125000,

        .bus_num = 2,

        .chip_select = GPIO_PG8,

        .controller_data = &ad5204_spi_chip_info,

        .mode = SPI_MODE_0,

    },

 

    {

        .modalias = "ad1938-spi",

        .max_speed_hz = 3125000,

        .bus_num = 2,

        .chip_select = GPIO_PG4,

        .controller_data = &ad1938_second_spi_chip_info,

        .mode = SPI_MODE_0,

    },

 

 

I am getting the following error messages on startup, which I don't yet know how to interpret.

 

bfin-spi bfin-spi.0: Blackfin BF5xx on-chip SPI Contoller Driver, Version 1.0, regs_base@ffc00500, dma channel@7

bfin-spi-gpio-mstr: registering platform driver

bfin-spi-gpio-mstr: bfin_spi_gpio_probe()

bits_per_word not specified in spi_bitbang_setup.  Defaulting to 32.

bits_per_word not specified in spi_bitbang_setup.  Defaulting to 32.

bits_per_word not specified in spi_bitbang_setup.  Defaulting to 32.

Advanced Linux Sound Architecture Driver Version 1.0.12rc1 (Thu Jun 22 13:55:50 2006 UTC).

dma_alloc_init: dma_page @ 0x00392000 - 256 pages at 0x03f00000

snd_ad1938_configure

kobject_add failed for AD1938.0 with -EEXIST, don't try to register things with the same name in the same directory.

Hardware Trace:

   0 Target : <0x000047f8> { _dump_stack + 0x0 }

     Source : <0x00098a2c> { _kobject_shadow_add + 0xd4 }

   1 Target : <0x00098a2c> { _kobject_shadow_add + 0xd4 }

     Source : <0x00098a70> { _kobject_shadow_add + 0x118 }

   2 Target : <0x00098a70> { _kobject_shadow_add + 0x118 }

     Source : <0x0000d9b2> { _printk + 0x16 }

   3 Target : <0x0000d9ae> { _printk + 0x12 }

     Source : <0x0000d86c> { _vprintk + 0x1c0 }

   4 Target : <0x0000d864> { _vprintk + 0x1b8 }

     Source : <0xffa00d2c> { __common_int_entry + 0xcc }

   5 Target : <0xffa00cca> { __common_int_entry + 0x6a }

     Source : <0xffa00b12> { _return_from_int + 0x4e }

   6 Target : <0xffa00b12> { _return_from_int + 0x4e }

     Source : <0xffa00af2> { _return_from_int + 0x2e }

   7 Target : <0xffa00ac4> { _return_from_int + 0x0 }

     Source : <0xffa00cc6> { __common_int_entry + 0x66 }

   8 Target : <0xffa00cc4> { __common_int_entry + 0x64 }

     Source : <0xffa00f76> { _do_irq + 0x8e }

   9 Target : <0xffa00f72> { _do_irq + 0x8a }

     Source : <0xffa00424> { _asm_do_IRQ + 0x68 }

  10 Target : <0xffa0041c> { _asm_do_IRQ + 0x60 }

     Source : <0x00011f5e> { _irq_exit + 0x3e }

  11 Target : <0x00011f5a> { _irq_exit + 0x3a }

     Source : <0x00011c6e> { ___do_softirq + 0x96 }

  12 Target : <0x00011c68> { ___do_softirq + 0x90 }

     Source : <0x00011b62> { __local_bh_enable + 0x3e }

  13 Target : <0x00011b24> { __local_bh_enable + 0x0 }

     Source : <0x00011c64> { ___do_softirq + 0x8c }

  14 Target : <0x00011c64> { ___do_softirq + 0x8c }

     Source : <0x00011c44> { ___do_softirq + 0x6c }

  15 Target : <0x00011c38> { ___do_softirq + 0x60 }

     Source : <0x00011d4c> { _tasklet_action + 0x7c }

Stack from 00275d54:

        00275d58 00275d78 00098a30 002b6e00 ffffffef 00000000 00397a74 0000001f

        00397a74 00275da0 00098abe 002b6e00 00397a08 001c6554 0019de10 00000000

        00397a08 0019de10 00000000 00275dc8 000b2450 00000000 00275de4 00397aac

        00397aac 00397a00 001c6554 00397a00 00000000 00275e00 000b6040 002b6e00

        00397a00 001c6554 00000000 00000000 001a0290 00000000 00275e04 000b619e

        00397a00 00397b5c 00000000 00275e24 000b6222 002b6e00 001a0290 00397a00

 

Call Trace:

[<00069a84>] _sysfs_create_link+0xc4/0x128

[<000e66b0>] _snd_ad1938_spi_probed+0x28/0x74

[<0000a1ff>] _show_state_filter+0x157/0x15c

[<000e49f8>] _ad1938_spi_probe+0x34/0x48

[<000cb3b8>] _spi_drv_probe+0x18/0x2c

[<000b4520>] _driver_probe_device+0x64/0x17c

[<000b4536>] _driver_probe_device+0x7a/0x17c

[<00139a56>] _klist_next+0x36/0x60

[<000b4812>] ___driver_attach+0xfa/0x104

[<000b3a0a>] _bus_for_each_dev+0x36/0x64

[<000b4718>] ___driver_attach+0x0/0x104

[<000b43ea>] _driver_attach+0x1a/0x20

[<000b4718>] ___driver_attach+0x0/0x104

[<000b3d44>] _bus_add_driver+0x64/0x164

[<000b4a1a>] _driver_register+0x42/0x74

[<000cb22a>] _spi_register_driver+0x4e/0x54

[<000081a4>] _l1_data_sram_free+0x8/0x28

[<000e4a34>] _ad1938_spi_init+0x10/0x18

[<001b1f52>] _snd_ad1938_init+0x26/0x50

[<001a66b6>] _kernel_init+0x8a/0x238

[<001a662c>] _kernel_init+0x0/0x238

[<00001676>] _kernel_thread_helper+0x6/0xc

 

NULL pointer access (probably)

Kernel OOPS in progress

Defered Exception context

CURRENT PROCESS:

COMM=swapper PID=1

invalid mm

return address: [0x00139a8a]; contents of:

0x00139a60:  3045  0064  e801  0000  3006  05b3  0010  ac5a

0x00139a70:  3042  0807  17eb  6006  2fef  ac5a  9117  2fe3

0x00139a80:  04c4  3228  e800  0003  916a [acd4] e3ff  ffbe

0x00139a90:  0c00  1c05  0c44  1803  3045  0064  e801  0000

 

SEQUENCER STATUS:               Not tainted

SEQSTAT: 00000027  IPEND: 8030  SYSCFG: 0006

  HWERRCAUSE: 0x0

  EXCAUSE   : 0x27

  physical IVG15 asserted : <0xffa00e80> { _evt_system_call + 0x0 }

  logical irq   6 mapped  : <0xffa00288> { _timer_interrupt + 0x0 }

  logical irq  12 mapped  : <0x000e4e6c> { _rx_handler + 0x0 }

  logical irq  13 mapped  : <0x000e4e0c> { _tx_handler + 0x0 }

  logical irq  24 mapped  : <0x000bb124> { _bf537mac_interrupt + 0x0 }

  logical irq  45 mapped  : <0x000e522c> { _err_handler + 0x0 }

RETE: <0x00000000> /* Maybe null pointer? */

RETN: <0x00275cf4> /* unknown address */

RETX: <0x00139a8a> { _klist_del + 0xa }

RETS: <0x00139b12> { _klist_remove + 0xe }

PC  : <0x00139a8a> { _klist_del + 0xa }

DCPLB_FAULT_ADDR: <0x0000000c> /* Maybe null pointer? */

ICPLB_FAULT_ADDR: <0x00139a8a> { _klist_del + 0xa }

 

PROCESSOR STATE:

R0 : 001a02e4    R1 : 001a0290    R2 : 0000001f    R3 : 00000000

R4 : 00000000    R5 : 001a035c    R6 : 000000d8    R7 : 001a02f4

P0 : 001753cd    P1 : 002b766c    P2 : 00000000    P3 : 0019f630

P4 : 001a0290    P5 : 001a02e4    FP : 00275d00    SP : 00275c18

LB0: ffa01d7c    LT0: ffa01d7a    LC0: 00000000

LB1: 0009bfe0    LT1: 0009bfd6    LC1: 00000000

B0 : 00000000    L0 : 00000000    M0 : 00000000    I0 : 00397a7c

B1 : 00000000    L1 : 00000000    M1 : 00000000    I1 : 00000000

B2 : 00000000    L2 : 00000000    M2 : 00000000    I2 : fffedbaf

B3 : 00000000    L3 : 00000000    M3 : 00000000    I3 : 00000000

A0.w: 0000002d   A0.x: 00000000   A1.w: 0000002d   A1.x: 00000000

USP : 00000000  ASTAT: 00002020

 

Hardware Trace:

   0 Target : <0x0000491c> { _trap_c + 0x0 }

     Source : <0xffa007ac> { _exception_to_level5 + 0xb4 }

   1 Target : <0xffa006f8> { _exception_to_level5 + 0x0 }

     Source : <0xffa00654> { _ex_trap_c + 0x68 }

   2 Target : <0xffa00824> { _trap + 0x0 }

     Source : <0x00139a88> { _klist_del + 0x8 }

   3 Target : <0x00139a80> { _klist_del + 0x0 }

     Source : <0x00139b0e> { _klist_remove + 0xa }

   4 Target : <0x00139b04> { _klist_remove + 0x0 }

     Source : <0x000b3ea2> { _bus_remove_driver + 0x5e }

   5 Target : <0x000b3e9a> { _bus_remove_driver + 0x56 }

     Source : <0x000b3e76> { _bus_remove_driver + 0x32 }

   6 Target : <0x000b3e6e> { _bus_remove_driver + 0x2a }

     Source : <0x000b4a9c> { _driver_remove_file + 0x28 }

   7 Target : <0x000b4a96> { _driver_remove_file + 0x22 }

     Source : <0x000b4a5a> { _put_driver + 0xe }

   8 Target : <0x000b4a56> { _put_driver + 0xa }

     Source : <0x00098652> { _kobject_put + 0x1a }

   9 Target : <0x0009864e> { _kobject_put + 0x16 }

     Source : <0x00099256> { _kref_put + 0x42 }

  10 Target : <0x00099214> { _kref_put + 0x0 }

     Source : <0x0009864a> { _kobject_put + 0x12 }

  11 Target : <0x00098638> { _kobject_put + 0x0 }

     Source : <0x000b4a52> { _put_driver + 0x6 }

  12 Target : <0x000b4a4c> { _put_driver + 0x0 }

     Source : <0x000b4a92> { _driver_remove_file + 0x1e }

  13 Target : <0x000b4a90> { _driver_remove_file + 0x1c }

     Source : <0x00068040> { _sysfs_remove_file + 0x14 }

  14 Target : <0x0006803c> { _sysfs_remove_file + 0x10 }

     Source : <0x00067982> { _sysfs_hash_and_remove + 0x16 }

  15 Target : <0x0006797a> { _sysfs_hash_and_remove + 0xe }

     Source : <0x000679f2> { _sysfs_hash_and_remove + 0x86 }

Stack from 00275bf4:

        003d08ba 00275d00 ffa007b0 00196560 00196560 0019655c 00000026 00000000

        00000001 00139a8a 00008030 00000027 00000000 00275cf4 00139a8a 00139a8a

        00139b12 001a02e4 00002020 0009bfe0 ffa01d7c 0009bfd6 ffa01d7a 00000000

        00000000 0000002d 00000000 0000002d 00000000 00000000 00000000 00000000

        00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

        00000000 00000000 fffedbaf 00000000 00397a7c 00000000 00275d00 001a02e4

 

Call Trace:

[<000b4a56>] _put_driver+0xa/0x10

[<00139b12>] _klist_remove+0xe/0x1c

[<000b3ea6>] _bus_remove_driver+0x62/0x84

[<000e5fb8>] _snd_ad1938_set_register+0x24/0x30

[<000b49d0>] _driver_unregister+0x8/0x10

[<00139a1a>] _klist_dec_and_del+0x12/0x18

[<000e4a1c>] _ad1938_spi_done+0x10/0x18

[<000e67a4>] _snd_ad1938_remove+0x18/0x40

[<000e67aa>] _snd_ad1938_remove+0x1e/0x40

[<00018130>] _blocking_notifier_call_chain+0x10/0x18

[<000b5c80>] _platform_drv_remove+0x14/0x1c

[<00067a54>] _sysfs_hash_and_remove+0xe8/0x104

[<000b43aa>] ___device_release_driver+0x66/0x8c

[<000b4984>] _driver_detach+0xf0/0x114

[<00139b18>] _klist_remove+0x14/0x1c

[<000b3eac>] _bus_remove_driver+0x68/0x84

[<000b1afc>] _put_device+0x14/0x1c

[<000b619e>] _platform_device_alloc+0x3e/0x68

[<000b49d0>] _driver_unregister+0x8/0x10

[<000b622e>] _platform_device_register_simple+0x2a/0x58

[<000b5e26>] _platform_driver_unregister+0xa/0x10

[<00069a84>] _sysfs_create_link+0xc4/0x128

[<000e66b0>] _snd_ad1938_spi_probed+0x28/0x74

[<000e66f8>] _snd_ad1938_spi_probed+0x70/0x74

[<0000a1ff>] _show_state_filter+0x157/0x15c

[<000e49f8>] _ad1938_spi_probe+0x34/0x48

[<000cb3b8>] _spi_drv_probe+0x18/0x2c

[<000b4520>] _driver_probe_device+0x64/0x17c

[<000b4536>] _driver_probe_device+0x7a/0x17c

[<00139a56>] _klist_next+0x36/0x60

[<000b4812>] ___driver_attach+0xfa/0x104

[<000b3a0a>] _bus_for_each_dev+0x36/0x64

[<000b4718>] ___driver_attach+0x0/0x104

[<000b43ea>] _driver_attach+0x1a/0x20

[<000b4718>] ___driver_attach+0x0/0x104

[<000b3d44>] _bus_add_driver+0x64/0x164

[<000b4a1a>] _driver_register+0x42/0x74

[<000cb22a>] _spi_register_driver+0x4e/0x54

[<000081a4>] _l1_data_sram_free+0x8/0x28

[<000e4a34>] _ad1938_spi_init+0x10/0x18

[<001b1f52>] _snd_ad1938_init+0x26/0x50

[<001a66b6>] _kernel_init+0x8a/0x238

[<001a662c>] _kernel_init+0x0/0x238

[<00001676>] _kernel_thread_helper+0x6/0xc

 

Modules linked in:

Kernel panic - not syncing: Kernel exception

QuoteReplyEditDelete

 

 

2009-04-07 17:15:47     Re: Supporting two AD1836 codecs (on separate SPORT interfaces)

Mike Frysinger (UNITED STATES)

Message: 72367   

 

you'll have to also change the DRIVER_NAME in the file ... that method may be the shortest route to success ...

QuoteReplyEditDelete

 

 

2009-04-07 17:25:55     Re: Supporting two AD1836 codecs (on separate SPORT interfaces)

Steve Strobel (UNITED STATES)

Message: 72370   

 

Mike Frysinger wrote:

 

> yes, the current driver only supports one instance ...

> in order to fix, all global state needs to be moved into

> private data and allocated on the fly in the

> snd_ad1836_probe() function.

 

I think I understand how to go about doing that.  I am still fuzzy, however, on how to go about creating the second instance of the sound driver.  I see how the various stamp_devices are set up in arch/blackfin/mach-bf537/boards/target.c, but I don't see the sound interfaces there (although the SPI and SPORT which are used to communicate with the codec chips are).  I also see how sound/blackfin/Kconfig and sound/blackfin/Makefile control whether the driver is compiled.  I just don't know what actually causes the sound device to be created.  What am I missing?

 

Steve

QuoteReplyEditDelete

 

 

2009-04-07 19:34:40     Re: Supporting two AD1836 codecs (on separate SPORT interfaces)

Mike Frysinger (UNITED STATES)

Message: 72373   

 

the ad1836.c driver is a good example of how to not architect things ... it's why it's deprecated in favor of the alsa soc framework (not that there's a driver replacement for the ad1836 codec yet)

 

the platform resources declare the spi resources for the ad1836

 

snd_ad1836_init() is always called via module_init()

- registers the driver "AD1836"

- calls ad1836_spi_init()

 

ad1836_spi_init() registers the spi driver "ad1836-spi"

 

the common spi framework detects the match between the platform resources and the ad1836-spi driver

 

ad1836_spi_probe() is called which turns around and calls snd_ad1836_spi_probed()

 

snd_ad1836_spi_probed() dynamically registers platform resources for "AD1836"

 

the common platform framework detects the match between the platform resources and the AD1836 driver

 

snd_ad1836_probe() is called

 

i think you can take it from there ...

QuoteReplyEditDelete

 

 

2009-04-08 13:02:05     Re: Supporting two AD1836 codecs (on separate SPORT interfaces)

Steve Strobel (UNITED STATES)

Message: 72425   

 

Thanks, Mike, for all of the info about how drivers get registered.  I just read (re)read driver-model/platform.txt;  I think I mostly understand how the stamp_devices array is used to create platform devices and how they are bound to drivers.  I don't see anything in there about creating the sound "card", though, that I could duplicate to create the second one.  I am guessing that sound devices are not created as platform devices, but I haven't been able to find where they are created.  ALSA-Configuration says that the device nodes can be created by calling /dev/MAKEDEV or using the snddevices script, but I haven't found either of them.

 

It appears to create the device when it initializes ALSA, as the following gets printed at startup:

 

Advanced Linux Sound Architecture Driver Version 1.0.12rc1 (Thu Jun 22 13:55:50 2006 UTC).

dma_alloc_init: dma_page @ 0x003a0000 - 256 pages at 0x03f00000

snd_ad1836_configure

ALSA device list:

  #0: ADI ad1836 at PF4 SPORT1 rx/tx dma 5/6 err irq 46

 

and it shows up in /proc/asound:

 

root:~> cd /proc/asound

root:/proc/asound> ls -l

lrwxrwxrwx    1 root     root            5 Dec 31 16:00 ad1836 -> card0

dr-xr-xr-x    4 root     root            0 Dec 31 16:00 card0

-r--r--r--    1 root     root            0 Dec 31 16:00 cards

-r--r--r--    1 root     root            0 Dec 31 16:00 devices

dr-xr-xr-x    2 root     root            0 Dec 31 16:00 oss

-r--r--r--    1 root     root            0 Dec 31 16:00 pcm

-r--r--r--    1 root     root            0 Dec 31 16:00 timers

-r--r--r--    1 root     root            0 Dec 31 16:00 version

root:/proc/asound> cat cards

0 [ad1836         ]: AD1836 - ADI ad1836

                      ADI ad1836 at PF4 SPORT1 rx/tx dma 5/6 err irq 46

 

Thanks for any pointers to where the sound "card" is created.

 

Steve

QuoteReplyEditDelete

 

 

2009-04-08 13:11:34     Re: Supporting two AD1836 codecs (on separate SPORT interfaces)

Steve Strobel (UNITED STATES)

Message: 72427   

 

I think I can answer my own question.  It appears that the AD1836 driver not only registers itself as a driver, but creates the device too.  There is no platform_device or platform_data structure with the data for the device, so the driver just uses the configuration options (like SND_BLACKFIN_SPORT) directly.  Cleaning all of that up so the driver can support multiple devices would be complicated.  I think I will pursue the copy-the-driver method, as it will automatically create another device.  Did I miss anything?

 

Steve

QuoteReplyEditDelete

 

 

2009-04-08 16:55:47     Re: Supporting two AD1836 codecs (on separate SPORT interfaces)

Mike Frysinger (UNITED STATES)

Message: 72437   

 

right, snd_ad1836_spi_probed() registers platform resources dynamically

 

you'll have to copy ad1836.c and ad1836_spi.c and make sure to change the driver name used in both (look for ".name" fields)

QuoteReplyEditDelete

 

 

2009-04-08 22:29:17     Re: Supporting two AD1836 codecs (on separate SPORT interfaces)

Cliff Cai (CHINA)

Message: 72441   

 

Steve,

 

You can refer to AD73322 driver,it does support two instances.It supports one card on SPORT0 the other on SPORT1 at the same time.See snd_ad73322_init() and snd_ad73322_probe()

 

 

 

Cliff

QuoteReplyEditDelete

 

 

2009-04-09 17:39:47     Serial/SPORT DMA conflict? (was Supporting two AD1836 codecs...)

Steve Strobel (UNITED STATES)

Message: 72480   

 

Mike Frysinger wrote:

> ...you'll have to copy ad1836.c and ad1836_spi.c and make sure to

> change the driver name used in both (look for ".name" fields)

 

It took a little tweaking to avoid link-time and run-time conflicts, but that seems to be working well.  Thanks for the advice.  On startup I now see:

 

    snd_ad1938_configure

    snd_ad1938_configure

    ALSA device list:

      #0: ADI ad1938 at PF3 SPORT0 rx/tx dma 3/4 err irq 45

      #1: ADI ad1938 at PF4 SPORT1 rx/tx dma 5/6 err irq 46

 

After boot, I can telnet to it and inspect codec registers using cat /proc/asound/card0/registers;  that works fine.  I changed to a dummy startup script, so it isn't running anything except the drivers on startup.

 

I now have a new problem that may be related to the DMA resources used by the second codec driver;  after booting if I press any key in my RS-232 serial terminal program it causes a stack dump (shown below).  I can, however, successfully telnet to it, inspect codec registers using cat /proc/asound/card0/registers, etc.  I haven't tried running audio through it yet.  It will run for a long time if I don't send it any serial, but as soon as I do, it dumps as shown below.

 

Linux version 2.6.22.19-ADI-2008R1.5-svn477 (stevestrobel@dev1-ubuntu) (gcc version 4.1.2 (ADI svn)) #30 Thu Apr 9 14:37

:24 MDT 2009

Hardware Trace Active and Enabled

Blackfin support (C) 2004-2007 Analog Devices, Inc.

Compiled for ADSP-BF537 Rev 0.3

Blackfin Linux support by   blackfin.uclinux.org/

Processor Speed: 500 MHz core clock and 100 MHz System Clock

Board Memory: 64MB

Kernel Managed Memory: 64MB

Memory map:

  text      = 0x00001000-0x0013b980

  rodata    = 0x0013c000-0x00190ddc

  data      = 0x00191000-0x001a6000

    stack   = 0x00192000-0x00194000

  init      = 0x001a6000-0x001b9000

  bss       = 0x001b9000-0x001c9f10

  available = 0x001c9f10-0x02700000

  rootfs    = 0x02700000-0x03f00000

  DMA Zone  = 0x03f00000-0x04000000

NOMPU: setting up cplb tables for global access

Instruction Cache Enabled

Data Cache Enabled (write-back)

Built 1 zonelists.  Total pages: 9906

Kernel command line: root=/dev/mtdblock0 rw console=ttyBF0,115200

Configuring Blackfin Priority Driven Interrupts

PID hash table entries: 256 (order: 8, 1024 bytes)

Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)

Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)

Memory available: 37528k/65536k RAM, (76k init code, 1258k kernel code, 493k data, 1024k dma, 584k reserved)

Blackfin Scratchpad data SRAM: 4 KB

Blackfin Data A SRAM: 16 KB (15 KB free)

Blackfin Data B SRAM: 16 KB (16 KB free)

Blackfin Instruction SRAM: 48 KB (39 KB free)

Security Framework v1.0.0 initialized

Capability LSM initialized

Mount-cache hash table entries: 512

NET: Registered protocol family 16

Blackfin GPIO Controller

Blackfin DMA Controller

tcb_406_board_init(): registering device resources

tcb_406_board_init(): registering Blackfin SPI resources

tcb_406_board_init(): finished registering Blackfin SPI resources

Generic PHY: Registered new driver

SCSI subsystem initialized

NET: Registered protocol family 2

IP route cache hash table entries: 1024 (order: 0, 4096 bytes)

TCP established hash table entries: 2048 (order: 2, 16384 bytes)

TCP bind hash table entries: 2048 (order: 1, 8192 bytes)

TCP: Hash tables configured (established 2048 bind 2048)

TCP reno registered

JFFS2 version 2.2. (NAND) © 2001-2006 Red Hat, Inc.

io scheduler noop registered

io scheduler anticipatory registered (default)

io scheduler cfq registered

ISA-BlackFin-CAN CAN Driver 3.4.6_AD_BLACKFIN (c) Apr  8 2009

BlackFin port by H.J. Oertel (oe@port.de)

bfin-wdt: initialized: timeout=20 sec (nowayout=0)

RLC-DSP4 cors driver

MSAT-IP init_switch driver

RLC-DSP4 ptts driver

Serial: Blackfin serial driver

bfin-uart.1: ttyBF0 at MMIO 0xffc00400 (irq = 18) is a BFIN-UART

bfin-uart.1: ttyBF1 at MMIO 0xffc02000 (irq = 20) is a BFIN-UART

RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize

bfin_mac_mdio: probed

bfin_mac: attached PHY driver [Generic PHY] (mii_bus:phy_addr=0:01, irq=-1, mdc_clk=2500000Hz(mdc_div=19)@sclk=100MHz)

bfin_mac: Version 1.1, Blackfin BF53[67] BF527 on-chip Ethernet MAC driver

uclinux[mtd]: RAM probe address=0x2700000 size=0x1800000

Creating 1 MTD partitions on "RAM":

0x00000000-0x01800000 : "ROMfs"

m25p80 spi0.1: m25p128 (16384 Kbytes)

Creating 4 MTD partitions on "m25p80":

0x00000000-0x00040000 : "bootloader"

0x00040000-0x00080000 : "bootloader-environment"

0x00080000-0x00e00000 : "kernel"

0x00e00000-0x01000000 : "file system"

bfin-spi bfin-spi.0: Blackfin BF5xx on-chip SPI Contoller Driver, Version 1.0, regs_base@ffc00500, dma channel@7

bfin-spi-gpio-mstr: registering platform driver

bfin-spi-gpio-mstr: bfin_spi_gpio_probe()

bits_per_word not specified in spi_bitbang_setup.  Defaulting to 32.

bits_per_word not specified in spi_bitbang_setup.  Defaulting to 32.

bits_per_word not specified in spi_bitbang_setup.  Defaulting to 32.

bits_per_word not specified in spi_bitbang_setup.  Defaulting to 32.

Advanced Linux Sound Architecture Driver Version 1.0.12rc1 (Thu Jun 22 13:55:50 2006 UTC).

dma_alloc_init: dma_page @ 0x02690000 - 256 pages at 0x03f00000

snd_ad1938_configure

snd_ad1938_configure

ALSA device list:

  #0: ADI ad1938 at PF3 SPORT0 rx/tx dma 3/4 err irq 45

  #1: ADI ad1938 at PF4 SPORT1 rx/tx dma 5/6 err irq 46

TCP cubic registered

NET: Registered protocol family 1

NET: Registered protocol family 17

VFS: Mounted root (ext2 filesystem).

Freeing unused kernel memory: 76k freed

                           _____________________________________

        a8888b.           / Welcome to the uClinux distribution \

       d888888b.         /       _     _                         \

       8P"YP"Y88        /       | |   |_|            __  __ (TM)  |

       8|o||o|88  _____/        | |    _ ____  _   _ \ \/ /       |

       8'    .88       \        | |   | |  _ \| | | | \  /        |

       8`._.' Y8.       \       | |__ | | | | | |_| | /  \        |

      d/      `8b.       \      \____||_|_| |_|\____|/_/\_\       |

     dP   .    Y8b.       \   For embedded processors including   |

    d8:'  "  `::88b        \    the Analog Devices Blackfin      /

   d8"         'Y88b        \___________________________________/

  :8P    '      :888

   8a.   :     _a88P         For further information, check out:

._/"Yaa_:   .| 88P|            -   blackfin.uclinux.org/

\    YP"    `| 8P  `.          -   docs.blackfin.uclinux.org/

/     \.___.d|    .'           -   www.uclinux.org/

`--..__)8888P`._.'  jgs/a:f    -   www.analog.com/blackfin

 

Have a lot of fun...

This is /mnt/permanent/scripts/init-passwd

Checking for password file

Password file already exists

Password file exists - using it

 

 

BusyBox v1.4.1 (2009-04-08 18:09:09 MDT) Built-in shell (msh)

Enter 'help' for a list of built-in commands.

 

root:~>

 

To prevent start-all from being executed automatically, reboot and as

soon as you see the uClinux banner above (before it gets here), type

"stop" and press ENTER.

 

Dummy startup script...

PHY: 0:01 - Link is Up - 100/Full

 

[It will run here until I send it a serial character, after which...]

 

 

NULL pointer access (probably)

Kernel OOPS in progress

Defered Exception context

 

No Valid process in current context

return address: [0x000b13d0]; contents of:

0x000b13b0:  081a  303a  185a  3067  3028  67f4  680b  204e

0x000b13c0:  6801  600f  e522  0025  a1e1  3001  4c08  5a91

0x000b13d0: [9952] ae22  5430  0c00  9155  141b  e6ba  ffff

0x000b13e0:  e6bd  fffe  e528  0044  0c40  1874  0000  acc1

 

SEQUENCER STATUS:               Not tainted

SEQSTAT: 00000027  IPEND: c030  SYSCFG: 0006

  HWERRCAUSE: 0x0

  EXCAUSE   : 0x27

  physical IVG14 asserted : <0xffa00b20> { _evt14_softirq + 0x0 }

  physical IVG15 asserted : <0xffa00e80> { _evt_system_call + 0x0 }

  logical irq   6 mapped  : <0xffa00288> { _timer_interrupt + 0x0 }

  logical irq  12 mapped  : <0x000e4e90> { _rx_handler + 0x0 }

  logical irq  13 mapped  : <0x000e4e30> { _tx_handler + 0x0 }

  logical irq  14 mapped  : <0x000e4e90> { _rx_handler + 0x0 }

  logical irq  15 mapped  : <0x000e4e30> { _tx_handler + 0x0 }

  logical irq  18 mapped  : <0x000b128c> { _bfin_serial_dma_rx_int + 0x0 }

  logical irq  19 mapped  : <0x000b11f0> { _bfin_serial_dma_tx_int + 0x0 }

  logical irq  24 mapped  : <0x000bb124> { _bf537mac_interrupt + 0x0 }

  logical irq  45 mapped  : <0x000e5250> { _err_handler + 0x0 }

  logical irq  46 mapped  : <0x000e5250> { _err_handler + 0x0 }

RETE: <0x00000000> /* Maybe null pointer? */

RETN: <0x00193dbc> /* unknown address */

RETX: <0x000b13d0> { _bfin_serial_rx_dma_timeout + 0xe0 }

RETS: <0x000b130e> { _bfin_serial_rx_dma_timeout + 0x1e }

PC  : <0x000b13d0> { _bfin_serial_rx_dma_timeout + 0xe0 }

DCPLB_FAULT_ADDR: <0x00000000> /* Maybe null pointer? */

ICPLB_FAULT_ADDR: <0x000b13d0> { _bfin_serial_rx_dma_timeout + 0xe0 }

 

PROCESSOR STATE:

R0 : 00000000    R1 : 00000000    R2 : 00000fff    R3 : 00000072

R4 : 00193dd2    R5 : 00000000    R6 : 00000000    R7 : 00000001

P0 : 0000000f    P1 : 00000000    P2 : 00000000    P3 : 00000001

P4 : 001c63a4    P5 : 001bff60    FP : 00193dd4    SP : 00193ce0

LB0: ffa01d7c    LT0: ffa01d7a    LC0: 00000000

LB1: 025f9aed    LT1: 025f9aec    LC1: 00000000

B0 : 00000000    L0 : 00000000    M0 : 00000000    I0 : 00000001

B1 : 00000000    L1 : 00000000    M1 : 00000000    I1 : 00000000

B2 : 00000000    L2 : 00000000    M2 : 00000000    I2 : 0004513c

B3 : 00000000    L3 : 00000000    M3 : 00000000    I3 : 00000000

A0.w: 000000a0   A0.x: 00000000   A1.w: 000000a0   A1.x: 00000000

USP : 00194000  ASTAT: 02002021

 

Hardware Trace:

   0 Target : <0x0000491c> { _trap_c + 0x0 }

     Source : <0xffa007ac> { _exception_to_level5 + 0xb4 }

   1 Target : <0xffa006f8> { _exception_to_level5 + 0x0 }

     Source : <0xffa00654> { _ex_trap_c + 0x68 }

   2 Target : <0xffa00824> { _trap + 0x0 }

     Source : <0x000b13ce> { _bfin_serial_rx_dma_timeout + 0xde }

   3 Target : <0x000b13c4> { _bfin_serial_rx_dma_timeout + 0xd4 }

     Source : <0x000b1466> { _bfin_serial_rx_dma_timeout + 0x176 }

   4 Target : <0x000b145a> { _bfin_serial_rx_dma_timeout + 0x16a }

     Source : <0x000b13be> { _bfin_serial_rx_dma_timeout + 0xce }

   5 Target : <0x000b13b0> { _bfin_serial_rx_dma_timeout + 0xc0 }

     Source : <0x000b1502> { _bfin_serial_rx_dma_timeout + 0x212 }

   6 Target : <0x000b14fc> { _bfin_serial_rx_dma_timeout + 0x20c }

     Source : <0x000b149c> { _bfin_serial_rx_dma_timeout + 0x1ac }

   7 Target : <0x000b1496> { _bfin_serial_rx_dma_timeout + 0x1a6 }

     Source : <0x000b13ac> { _bfin_serial_rx_dma_timeout + 0xbc }

   8 Target : <0x000b139a> { _bfin_serial_rx_dma_timeout + 0xaa }

     Source : <0x000b1380> { _bfin_serial_rx_dma_timeout + 0x90 }

   9 Target : <0x000b130e> { _bfin_serial_rx_dma_timeout + 0x1e }

     Source : <0x000072e2> { _get_dma_curr_xcount + 0x3e }

  10 Target : <0x000072a4> { _get_dma_curr_xcount + 0x0 }

     Source : <0x000b130a> { _bfin_serial_rx_dma_timeout + 0x1a }

  11 Target : <0x000b1300> { _bfin_serial_rx_dma_timeout + 0x10 }

     Source : <0x00007272> { _get_dma_curr_ycount + 0x3e }

  12 Target : <0x00007234> { _get_dma_curr_ycount + 0x0 }

     Source : <0x000b12fc> { _bfin_serial_rx_dma_timeout + 0xc }

  13 Target : <0x000b12f0> { _bfin_serial_rx_dma_timeout + 0x0 }

     Source : <0x00014abc> { _run_timer_softirq + 0xb4 }

  14 Target : <0x00014a92> { _run_timer_softirq + 0x8a }

     Source : <0x00014a72> { _run_timer_softirq + 0x6a }

  15 Target : <0x00014a24> { _run_timer_softirq + 0x1c }

     Source : <0x0001fe50> { _hrtimer_run_queues + 0xc8 }

Stack from 00193cbc:

        000ed990 00193dd4 ffa007b0 00196560 00196560 0019655c 00193d50 0012177a

        0028a940 000b13d0 0000c030 00000027 00000000 00193dbc 000b13d0 000b13d0

        000b130e 00000000 02002021 025f9aed ffa01d7c 025f9aec ffa01d7a 00000000

        00000000 000000a0 00000000 000000a0 00000000 00000000 00000000 00000000

        00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

        00000000 00000000 0004513c 00000000 00000001 00194000 00193dd4 001bff60

 

Call Trace:

[<00014abe>] _run_timer_softirq+0xb6/0x170

[<000b12f0>] _bfin_serial_rx_dma_timeout+0x0/0x224

[<00011c38>] ___do_softirq+0x60/0xac

[<00029d46>] _handle_simple_irq+0x72/0x94

[<00011f5a>] _irq_exit+0x3a/0x40

[<0001d768>] _kthreadd+0x0/0xe0

[<00008050>] __l1_sram_free+0x6c/0xc0

[<0004512b>] _flock_lock_file_wait+0x163/0x1f4

[<0000ffff>] _do_exit+0x2ab/0x774

[<0013a192>] _rest_init+0x42/0x48

[<00040000>] ___link_path_walk+0x8ec/0xc40

[<001a6a70>] _start_kernel+0x20c/0x22c

[<001a63ac>] _unknown_bootoption+0x0/0x220

[<001a61bc>] _real_start+0x50/0x94

 

Modules linked in:

Kernel panic - not syncing: Kernel exception

 

--------------------------

 

If I disable the second codec driver, it boots and accepts input from the serial port normally.  A log of that boot process follows for comparison:

 

Linux version 2.6.22.19-ADI-2008R1.5-svn477 (stevestrobel@dev1-ubuntu) (gcc version 4.1.2 (ADI svn)) #31 Thu Apr 9 15:14

:06 MDT 2009

Hardware Trace Active and Enabled

Blackfin support (C) 2004-2007 Analog Devices, Inc.

Compiled for ADSP-BF537 Rev 0.3

Blackfin Linux support by   blackfin.uclinux.org/

Processor Speed: 500 MHz core clock and 100 MHz System Clock

Board Memory: 64MB

Kernel Managed Memory: 64MB

Memory map:

  text      = 0x00001000-0x0013a470

  rodata    = 0x0013b000-0x0018f738

  data      = 0x00190000-0x001a4000

    stack   = 0x00190000-0x00192000

  init      = 0x001a4000-0x001b7000

  bss       = 0x001b7000-0x001c7ef0

  available = 0x001c7ef0-0x02200000

  rootfs    = 0x02200000-0x03f00000

  DMA Zone  = 0x03f00000-0x04000000

NOMPU: setting up cplb tables for global access

Instruction Cache Enabled

Data Cache Enabled (write-back)

Built 1 zonelists.  Total pages: 8636

Kernel command line: root=/dev/mtdblock0 rw console=ttyBF0,115200

Configuring Blackfin Priority Driven Interrupts

PID hash table entries: 256 (order: 8, 1024 bytes)

Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)

Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)

Memory available: 32416k/65536k RAM, (76k init code, 1253k kernel code, 490k data, 1024k dma, 584k reserved)

Blackfin Scratchpad data SRAM: 4 KB

Blackfin Data A SRAM: 16 KB (15 KB free)

Blackfin Data B SRAM: 16 KB (16 KB free)

Blackfin Instruction SRAM: 48 KB (39 KB free)

Security Framework v1.0.0 initialized

Capability LSM initialized

Mount-cache hash table entries: 512

NET: Registered protocol family 16

Blackfin GPIO Controller

Blackfin DMA Controller

tcb_406_board_init(): registering device resources

tcb_406_board_init(): registering Blackfin SPI resources

tcb_406_board_init(): finished registering Blackfin SPI resources

Generic PHY: Registered new driver

SCSI subsystem initialized

NET: Registered protocol family 2

IP route cache hash table entries: 1024 (order: 0, 4096 bytes)

TCP established hash table entries: 2048 (order: 2, 16384 bytes)

TCP bind hash table entries: 2048 (order: 1, 8192 bytes)

TCP: Hash tables configured (established 2048 bind 2048)

TCP reno registered

JFFS2 version 2.2. (NAND) © 2001-2006 Red Hat, Inc.

io scheduler noop registered

io scheduler anticipatory registered (default)

io scheduler cfq registered

ISA-BlackFin-CAN CAN Driver 3.4.6_AD_BLACKFIN (c) Apr  8 2009

BlackFin port by H.J. Oertel (oe@port.de)

bfin-wdt: initialized: timeout=20 sec (nowayout=0)

RLC-DSP4 cors driver

MSAT-IP init_switch driver

RLC-DSP4 ptts driver

Serial: Blackfin serial driver

bfin-uart.1: ttyBF0 at MMIO 0xffc00400 (irq = 18) is a BFIN-UART

bfin-uart.1: ttyBF1 at MMIO 0xffc02000 (irq = 20) is a BFIN-UART

RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize

bfin_mac_mdio: probed

bfin_mac: attached PHY driver [Generic PHY] (mii_bus:phy_addr=0:01, irq=-1, mdc_clk=2500000Hz(mdc_div=19)@sclk=100MHz)

bfin_mac: Version 1.1, Blackfin BF53[67] BF527 on-chip Ethernet MAC driver

uclinux[mtd]: RAM probe address=0x2200000 size=0x1d00000

Creating 1 MTD partitions on "RAM":

0x00000000-0x01d00000 : "ROMfs"

m25p80 spi0.1: m25p128 (16384 Kbytes)

Creating 4 MTD partitions on "m25p80":

0x00000000-0x00040000 : "bootloader"

0x00040000-0x00080000 : "bootloader-environment"

0x00080000-0x00e00000 : "kernel"

0x00e00000-0x01000000 : "file system"

bfin-spi bfin-spi.0: Blackfin BF5xx on-chip SPI Contoller Driver, Version 1.0, regs_base@ffc00500, dma channel@7

bfin-spi-gpio-mstr: registering platform driver

bfin-spi-gpio-mstr: bfin_spi_gpio_probe()

bits_per_word not specified in spi_bitbang_setup.  Defaulting to 32.

bits_per_word not specified in spi_bitbang_setup.  Defaulting to 32.

Advanced Linux Sound Architecture Driver Version 1.0.12rc1 (Thu Jun 22 13:55:50 2006 UTC).

dma_alloc_init: dma_page @ 0x003a2000 - 256 pages at 0x03f00000

snd_ad1938_configure

ALSA device list:

  #0: ADI ad1938 at PF3 SPORT0 rx/tx dma 3/4 err irq 45

TCP cubic registered

NET: Registered protocol family 1

NET: Registered protocol family 17

VFS: Mounted root (ext2 filesystem).

Freeing unused kernel memory: 76k freed

                           _____________________________________

        a8888b.           / Welcome to the uClinux distribution \

       d888888b.         /       _     _                         \

       8P"YP"Y88        /       | |   |_|            __  __ (TM)  |

       8|o||o|88  _____/        | |    _ ____  _   _ \ \/ /       |

       8'    .88       \        | |   | |  _ \| | | | \  /        |

       8`._.' Y8.       \       | |__ | | | | | |_| | /  \        |

      d/      `8b.       \      \____||_|_| |_|\____|/_/\_\       |

     dP   .    Y8b.       \   For embedded processors including   |

    d8:'  "  `::88b        \    the Analog Devices Blackfin      /

   d8"         'Y88b        \___________________________________/

  :8P    '      :888

   8a.   :     _a88P         For further information, check out:

._/"Yaa_:   .| 88P|            -   blackfin.uclinux.org/

\    YP"    `| 8P  `.          -   docs.blackfin.uclinux.org/

/     \.___.d|    .'           -   www.uclinux.org/

`--..__)8888P`._.'  jgs/a:f    -   www.analog.com/blackfin

 

Have a lot of fun...

This is /mnt/permanent/scripts/init-passwd

Checking for password file

Password file already exists

Password file exists - using it

 

 

BusyBox v1.4.1 (2009-04-08 18:09:09 MDT) Built-in shell (msh)

Enter 'help' for a list of built-in commands.

 

root:~>

 

To prevent start-all from being executed automatically, reboot and as

soon as you see the uClinux banner above (before it gets here), type

"stop" and press ENTER.

 

Dummy startup script...

PHY: 0:01 - Link is Up - 100/Full

 

root:~>

 

-------------------------------------

 

Am I getting serial RX DMA timeouts because of a conflict between the DMA resources used by the second AD1938 driver and the serial port driver?  Any other suggestions about what I should check?  Thanks.

 

Steve

QuoteReplyEditDelete

 

 

2009-04-09 19:21:49     Re: Serial/SPORT DMA conflict? (was Supporting two AD1836 codecs...)

Mike Frysinger (UNITED STATES)

Message: 72484   

 

hmm, if a dma channel was not available, the driver should have complained and disabled itself rather than crash

 

can you telnet into the board and cat /proc/dma with and without the second codec enabled ?

 

if you set the UART to PIO mode in the kernel config, does that work as well ?

QuoteReplyEditDelete

 

 

2009-04-10 11:28:11     Re: Serial/SPORT DMA conflict? (was Supporting two AD1836 codecs...)

Steve Strobel (UNITED STATES)

Message: 72510   

 

Mike Frysinger wrote:

> hmm, if a dma channel was not available, the driver should have complained and disabled itself rather than crash

 

Looking in the databook, it appears that the SPORT interfaces are using the default DMA channels.  Assuming the UART is also, there is no reason they would have a conflict.  I was just guessing that it was DMA related because of the stack dump.

 

> can you telnet into the board and cat /proc/dma with and without the second codec enabled ?

 

I don't seem to have that (virtual) file:

 

root:~> cat /proc/dma

cat: /proc/dma: No such file or directory

root:~> cd proc

root:/proc> ls

1            25           99           filesystems  maps         sram

136          3            asound       fs           meminfo      stat

152          37           buddyinfo    gpio         misc         sys

154          38           bus          interrupts   modules      sysvipc

157          39           cmdline      iomem        mounts       timer_list

158          4            cplbinfo     ioports      mtd          tty

159          40           cpuinfo      irq          net          uptime

171          5            devices      kallsyms     partitions   version

172          6            diskstats    kmsg         scsi         vmstat

174          77           driver       loadavg      self         zoneinfo

2            83           execdomains  locks        slabinfo

root:/proc> find -name dma

root:/proc>

 

> if you set the UART to PIO mode in the kernel config, does that work as well ?

 

Yes, it works fine in PIO mode.  I didn't realize that selection was avaliable.  I could just ignore the apparent DMA problem and go on using PIO mode, but it makes me kind of nervous.  Is there something else I should check?  Thanks for any suggestions.

 

Steve

QuoteReplyEditDelete

 

 

2009-04-10 11:34:37     Re: Serial/SPORT DMA conflict? (was Supporting two AD1836 codecs...)

Mike Frysinger (UNITED STATES)

Message: 72511   

 

hmm, /proc/dma is only in trunk and it doesnt seem to be complete anyways.  i'll have to dig into this.

QuoteReplyEditDelete

 

 

2009-04-10 13:44:08     Re: Serial/SPORT DMA conflict? (was Supporting two AD1836 codecs...)

Mike Frysinger (UNITED STATES)

Message: 72513   

 

erp, i lied ... /proc/dma is complete.  the board i was looking at had UART set to PIO mode for different reasons

 

please try the attached patch ... it should create a /proc/dma for you.  i didnt actually run-time test it though ...

 

i looked at both drivers and they seem to be doing the right thing (requesting dma and checking the return)

 

bfin-2008R1-proc-dma.patch

QuoteReplyEditDelete

 

 

2009-04-10 18:41:26     ALSA setup for two AD1336 codecs (was Supporting two AD1836 codecs)

Steve Strobel (UNITED STATES)

Message: 72527   

 

Mike Frysinger wrote:

> you'll have to copy ad1836.c and ad1836_spi.c and make sure to

> change the driver name used in both (look for ".name" fields)

 

I think all of that is set up (I haven't gotton back to trying DMA for the UARTs yet), but I am having trouble figuring out how to refer to the second sound interface.  My code was doing the following:

 

    if( snd_pcm_open( &pcm_input_handle, "default", SND_PCM_STREAM_CAPTURE, 0 ) < 0 )

 

I plan to call snd_pcm_open() twice, once for each AD1836 (actually AD1938), but I obviously can't refer to both of them as "default".  I have tried to figure out other ways to refer to each card, but the only other thing I have found that works is "pcm.hw" (from alsa.conf) and I don't know how to refer to a second one of those either.  Two sound "cards" exist in /proc/asound:

 

root:/proc/asound> ls

ad1938    card0     cards     oss       timers

ad1938_1  card1     devices   pcm       version

root:/proc/asound> cat cards

0 [ad1938         ]: AD1938 - ADI ad1938

                      ADI ad1938 at PF3 SPORT0 rx/tx dma 3/4 err irq 45

1 [ad1938_1       ]: AD1938_SECOND - ADI ad1938

                      ADI ad1938 at PF4 SPORT1 rx/tx dma 5/6 err irq 46

 

but I can't figure out how to open the PCM interface of the second one (or the first one by any name except "default" or "pcm.hw").  Maybe I need to create a second copy of something else?

 

root:/proc> cat /proc/devices

Character devices:

[snip]

116 alsa

 

apparently corresponds with the following from modprobe.conf:

 

# ALSA native device support

alias char-major-116 snd

options snd major=116 cards_limit=1

alias snd-card-0 snd-ad1836

 

Since my second driver is not called "snd-ad1836", I presume that I can't just change cards_limit to 2, but that I should copy that section and assign a different major number.  Even then, I don't know how that will help with the call to snd_pcm_open().  I would be happy to RTM if someone would point me to one with the answers   Thanks for any suggestions.

 

Steve

QuoteReplyEditDelete

 

 

2009-04-10 18:54:33     Re: ALSA setup for two AD1336 codecs (was Supporting two AD1836 codecs)

Mike Frysinger (UNITED STATES)

Message: 72528   

 

you'll probably have to copy AD1836.conf to AD1836_SECOND.conf in the romfs tree

QuoteReplyEditDelete

 

 

2009-04-10 19:24:05     Re: ALSA setup for two AD1336 codecs (was Supporting two AD1836 codecs)

Steve Strobel (UNITED STATES)

Message: 72529   

 

Mike Frysinger wrote:

> you'll probably have to copy AD1836.conf to AD1836_SECOND.conf in the romfs tree

 

I have done that.  Those files look like this:

 

AD1938.pcm.default {

    type plug

    slave {

        pcm {

            type mmap_emul

            slave {

                pcm {

                    type hw

                    card 0

                    format S32_LE

                    rate 16000                  

                }

            }

        }

    }

}

 

and

 

AD1938_SECOND.pcm.default { [snip]

 

They show up in /usr/share/alsa/cards.  Referring to AD1938.pcm.default when calling snd_pcm_open() doesn't seem to work, though.  After reading   alsa.opensrc.org/.asoundrc, I decided to try "hw:0,0" and "hw:1,0";  that seems to access the two cards.  I am now getting the messages, "Error setting HW params.  Input audio config: Cannot allocate memory" but at least it is looking at the "cards".  Thanks for your help.  More troubleshooting on Monday

 

Steve

QuoteReplyEditDelete

 

 

2009-04-12 23:51:53     Re: ALSA setup for two AD1336 codecs (was Supporting two AD1836 codecs)

Cliff Cai (CHINA)

Message: 72562   

 

see:  docs.blackfin.uclinux.org/doku.php?id=linux-kernel:drivers:ad73322

 

it gives an example of config file for  multi cards case.

 

 

 

Cliff

QuoteReplyEditDelete

 

 

2009-04-13 13:25:22     Re: ALSA setup for two AD1336 codecs (was Supporting two AD1836 codecs)

Steve Strobel (UNITED STATES)

Message: 72602   

 

Cliff Cai wrote:

> see:  docs.blackfin.uclinux.org/doku.php?id=linux-kernel:drivers:ad73322

> it gives an example of config file for  multi cards case.

 

I got that working.  Thanks.

 

Steve

QuoteReplyEditDelete

 

 

2009-04-13 13:44:04     snd_pcm_hw_params() cannot allocate memory (was Re: ALSA setup for two AD1336 codecs)

Steve Strobel (UNITED STATES)

Message: 72603   

 

Thanks to many suggestions in this tread, I have two AD1938 codec drivers loading on startup.  It prints:

 

    ALSA device list:

      #0: ADI ad1938 at PF3 SPORT0 rx/tx dma 3/4 err irq 45

      #1: ADI ad1938 at PF4 SPORT1 rx/tx dma 5/6 err irq 46

 

I access them from my userland code using hw:0,0 and hw:1,0 and ALSA finds them.  When I call snd_pcm_hw_params() for either one, it returns -12, which snd_strerror() interprets as "Cannot allocate memory".  I have about 7MB free, and this happens right after a reset when the memory shouldn't be fragmented, so I doubt that it is having trouble with allocating from the system heap.  Is there some kind of ALSA memory pool or anything that I might need to resize?  I have been trying to find where snd_pcm_hw_params() allocates memory, but haven't found it yet.

 

If I enable only one sound card driver, I can point it at either AD1938 (by changing the selected SPORT and PF pin) and either one will work fine using exactly the same userland code (and hw:0,0).  The userland code does not yet try to open both at the same time;  it fails as described above when the only change is enabling the second driver.

 

If I enable both drivers, everything seems fine until I try to open the sound interface.  I can run amixer to talk to either card, view the register contents using /proc/asound/card?/registers, etc.

 

Thanks for any suggestions.

 

Steve

QuoteReplyEditDelete

 

 

2009-04-13 17:48:42     Re: snd_pcm_hw_params() cannot allocate memory (was Re: ALSA setup for two AD1336 codecs)

Mike Frysinger (UNITED STATES)

Message: 72610   

 

does it allocate with kmalloc or a dma func ?  i'm pretty sure it's the latter which means you need to increase the dma buffer size in your kernel configuration (look under the Blackfin options).

QuoteReplyEditDelete

 

 

2009-04-14 13:40:07     Re: snd_pcm_hw_params() cannot allocate memory (was Re: ALSA setup for two AD1336 codecs)

Steve Strobel (UNITED STATES)

Message: 72646   

 

Mike Frysinger wrote:

> does it allocate with kmalloc or a dma func ?  i'm pretty sure it's the latter which means

> you need to increase the dma buffer size in your kernel configuration (look under the Blackfin options).

 

You are right.  Increasing the DMA region fixed that problem.  Thanks a bunch.

 

For anyone that might be looking for that option someday, it can be found in the kernel config > Blackfin Processor Options > Enable DMA Support > Uncached SDRAM region > Enable 2M DMA Region (changed from 1M to 2M).

Attachments

Outcomes