spidev: Instantiating from DT as "spidev"
Hello,
Since commit 956b200a846e ("spi: spidev: Warn loudly if instantiated from DT as "spidev""), listing "spidev" directly in a device tree is not recommended. Instead, what I see in the (many) past discussions is that I should change my device tree to describe the actual hardware and add whatever new ID I create to spidev_dt_ids. That seems perfectly reasonable.
However, our SPI master [1] is similar to the Raspberry Pi or Beaglebone in that we don't know at kernel build time what device may be attached to the SPI bus. Because the end users of our device are usually young students, we also can't expect them to rebuild their kernel or mess with device tree overlays just to interface with some arbitrary SPI device.
Is there a "correct" solution to this problem? Both the Raspberry Pi [2] and Beaglebone [3] kernels have just added "spidev" back to the match table, but I would rather not carry a patch around just for some printk spam.
Regards,
Signature · 12 lines
Kyle Roeschley Software Engineer National Instruments [1] http://www.ni.com/en-us/support/model.roborio.html [2] https://github.com/raspberrypi/linux/commit/dc08459ce87f0e73422c17abe20d0ac6c72153ad [3] https://github.com/beagleboard/linux/commit/1596f3a6a0966969089be73c58e4a6294ffbcb09 -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Kyle,
Quoted 12 lines · Kyle Roeschley
Since commit
956b200a846e("spi: spidev: Warn loudly if instantiated from DT as "spidev""), listing "spidev" directly in a device tree is not recommended. Instead, what I see in the (many) past discussions is that I should change my device tree to describe the actual hardware and add whatever new ID I create tospidev_dt_ids. That seems perfectly reasonable.However, our SPI master [1] is similar to the Raspberry Pi or Beaglebone in that we don't know at kernel build time what device may be attached to the SPI bus. Because the end users of our device are usually young students, we also can't expect them to rebuild their kernel or mess with device tree overlays just to interface with some arbitrary SPI device.
Quoted 3 lines
Is there a "correct" solution to this problem? Both the Raspberry Pi [2] and Beaglebone [3] kernels have just added "spidev" back to the match table, but I would rather not carry a patch around just for some printk spam.
Implement something in sysfs like "new_device" for i2c, or "slave" for SPI. Then people can add a new device (e.g. "spidev") by writing to that virtual file.
Documentation/i2c/instantiating-devicesDocumentation/spi/spi-summary
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): CAMuHMdUps9Ti=CRZM7UxrHLD8GA+FKD+_RFLW3H9wUpSRTYs8w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 4 lines · Geert Uytterhoeven
Implement something in sysfs like "
new_device" for i2c, or "slave" for SPI. Then people can add a new device (e.g. "spidev") by writing to that virtual file.
That makes sense to me. However, the i2c "new_device" and SPI "slave" nodes are simpler in that they only require the device name (and address for i2c). A SPI device can have many properties specified in the device tree that we would somehow need to get and parse. Two options I see would be:
1. Set device status to disabled in the DT and add the device when the name is written to the new_device sysfs node. But then, this is basically the same as just specifying "spidev" in the DT (minus the printks). I suppose we could also drop the compatible entry and require the user to specify a driver when writing to new_device.
2. Pass all parameters into the "new_device" node, e.g. by passing in and applying a DT overlay or snippet.
In my specific case [1], the device tree entires are simple, but I wouldn't expect that for everyone. I've hacked up the first option and it works, but it doesn't seem terribly useful. I noticed that you've been working with DT overlays recently; what do you think of the second option?
[1] https://github.com/ni/linux/blob/nilrt/17.0/4.6/arch/arm/boot/dts/ni-76F2.dts#L108
Signature · 7 lines
Kyle Roeschley Software Engineer National Instruments -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Kyle,
Quoted 18 lines · Kyle Roeschley
Quoted 3 lines · Geert Uytterhoeven
Implement something in sysfs like "
new_device" for i2c, or "slave" for SPI. Then people can add a new device (e.g. "spidev") by writing to that virtual file.That makes sense to me. However, the i2c "
new_device" and SPI "slave" nodes are simpler in that they only require the device name (and address for i2c). A SPI device can have many properties specified in the device tree that we would somehow need to get and parse. Two options I see would be:1. Set device status to disabled in the DT and add the device when the name is written to the
new_devicesysfs node. But then, this is basically the same as just specifying "spidev" in the DT (minus the printks). I suppose we could also drop the compatible entry and require the user to specify a driver when writing tonew_device.
2. Pass all parameters into the "new_device" node, e.g. by passing in and applying a DT overlay or snippet.
Quoted 6 lines
In my specific case [1], the device tree entires are simple, but I wouldn't expect that for everyone. I've hacked up the first option and it works, but it doesn't seem terribly useful. I noticed that you've been working with DT overlays recently; what do you think of the second option?
[1] https://github.com/ni/linux/blob/nilrt/17.0/4.6/arch/arm/boot/dts/ni-76F2.dts#L108
To me, the above sounds a bit contradictive: either you have
1. a simple (trivial) description, which can be handled by spidev and userspace, and thus by just writing "<unit-addr> spidev" to a new_device sysfs node, or
2. a complex description, for which you need a specialized in-kernel driver, so you're gonna need a real DT node (and overlays?) to describe it.
I don't think writing a complex description to a new_device sysfs node makes sense.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): CAMuHMdX62=vC6=P-v=SPe_hq0F12tOZCgePaS7=MZZg_4PkvUw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
T24gV2VkLCAyMDE3LTExLTI5IGF0IDIzOjE4ICswMTAwLCBHZWVydCBVeXR0ZXJob2V2ZW4gd3Jv dGU6DQo+IA0KPiBUbyBtZSwgdGhlIGFib3ZlIHNvdW5kcyBhIGJpdCBjb250cmFkaWN0aXZlOiBl aXRoZXIgeW91IGhhdmUNCj4gICAxLiBhIHNpbXBsZSAodHJpdmlhbCkgZGVzY3JpcHRpb24sIHdo aWNoIGNhbiBiZSBoYW5kbGVkIGJ5IHNwaWRldiBhbmQNCj4gICAgICB1c2Vyc3BhY2UsIGFu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IHdpdGggbmV3X2Rldmlj ZS4=
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi Trent,
Quoted 8 lines · Trent Piepho
Quoted 7 lines · Geert Uytterhoeven
To me, the above sounds a bit contradictive: either you have
1. a simple (trivial) description, which can be handled by spidev and userspace, and thus by just writing "<unit-addr> spidev" to anew_devicesysfs node, or
2. a complex description, for which you need a specialized in-kernel driver, so you're gonna need a real DT node (and overlays?) to describe it.
Quoted 5 lines
Quoted 2 lines
I don't think writing a complex description to a
new_devicesysfs node makes sense.Is there anything one can do with
new_devicethat can't be done with a dt fragment?
Nope.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): CAMuHMdXv2WsGCUBD4Td9K1zOfZ9DOfeW5rYtCyq27Ucp21xGRA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 8 lines · Geert Uytterhoeven
Hi Trent,
Quoted 5 lines · Trent Piepho
Quoted 4 lines · Geert Uytterhoeven
To me, the above sounds a bit contradictive: either you have
1. a simple (trivial) description, which can be handled by spidev and userspace, and thus by just writing "<unit-addr> spidev" to anew_devicesysfs node, or
So you're suggesting that new_device can only be used to create a device which uses spidev (without yelling about it)? That makes sense to me.
Quoted 10 lines
Quoted 8 lines
Quoted 5 lines
2. a complex description, for which you need a specialized in-kernel driver, so you're gonna need a real DT node (and overlays?) to describe it.
I don't think writing a complex description to a
new_devicesysfs node makes sense.Is there anything one can do with
new_devicethat can't be done with a dt fragment?Nope.
Aren't DT overlays via configfs not yet in mainline? So if I did want to use that mechanism, I'd have call the in-kernel API from within the SPI core.
Quoted 11 lines
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Signature · 7 lines
Kyle Roeschley Software Engineer National Instruments -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 19 lines · Kyle Roeschley
Quoted 8 lines · Geert Uytterhoeven
Hi Trent,
Quoted 5 lines · Trent Piepho
Quoted 4 lines · Geert Uytterhoeven
To me, the above sounds a bit contradictive: either you have
1. a simple (trivial) description, which can be handled by spidev and userspace, and thus by just writing "<unit-addr> spidev" to anew_devicesysfs node, orSo you're suggesting that
new_devicecan only be used to create a device which uses spidev (without yelling about it)? That makes sense to me.Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
2. a complex description, for which you need a specialized in-kernel driver, so you're gonna need a real DT node (and overlays?) to describe it.
I don't think writing a complex description to a
new_devicesysfs node makes sense.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Is there anything one can do with
new_devicethat can't be done with a dt fragment?Nope.
Aren't DT overlays via configfs not yet in mainline? So if I did want to use that mechanism, I'd have call the in-kernel API from within the SPI core.
Any more comments on this? If not, I'll create something like new_device and send it up.
Signature · 7 lines
Kyle Roeschley Software Engineer National Instruments -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
T24gV2VkLCAyMDE3LTExLTI5IGF0IDE3OjMyICswMTAwLCBHZWVydCBVeXR0ZXJob2V2ZW4gd3Jv dGU6DQo+IE9uIFdlZCwgTm92IDI5LCAyMDE3IGF0IDQ6MDQgUE0sIEt5bGUgUm9lc2NobGV5IDxr eWxlLnJvZXNjaGxleUBuaS5jb20+IHdyb3RlOg0KPiA+IFNpbmNlIGNvbW1pdCA5NTZiMjAwYT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XN0LiAgTm93IHRoYXQgd2UgaGF2 ZSBkeW5hbWljIGR0IGZyYWdtZW50IGxvYWRpbmcsIG1heWJlIHRoYXQNCmlzIGEgYmV0dGVyIHN5 c3RlbT8NCg0KT25lIGNhbiBjcmVhdGUgYSBkdCBmcmFnbWVudCB0aGF0IGFkZHMgYSBuZXcgc3Bp IGRldmljZSwgYW5kIHRoaXMgZ2l2ZXMNCnlvdSB0aGUgYWJpbGl0eSB0byBhZGQgYWxsIHRoZSBw cm9wZXJ0aWVzIHRoZSBkZXZpY2UgbWlnaHQgbmVlZCAoc3BpDQptb2RlLCBzcGVlZCwgZGV2aWNl IHNwZWNpZmljIHBhcmFtZXRlcnMsIGV0Yy4pLiAgSXQgY291bGQgYmluZCB0byBhbiANCm5vcm1h bCBzcGktc2xhdmUga2VybmVsIGRyaXZlciBvciB0byBzcGlkZXYuDQoNCklmIGFkZGluZyBhIGR0 IGZyYWdtZW50IGlzICJ0b28gaGFyZCIsIGp1c3Qgd3JhcCBpdCBpbiBhIHNjcmlwdC4gIEl0DQpz aG91bGQgYmUgdHJpdmlhbCB0byB3cml0ZSBhIHNjcmlwdCB0aGF0IHRha2VzIGEgc3BpIGJ1cyBh bmQgY2hpcA0Kc2VsZWN0IGFuZCBwcm9kdWNlcyBhIGdlbmVyaWMgZHQgZnJhZ21lbnQgd2l0aCB0 aG9zZSBmaWVsZHMgcGx1Z2dlZCBpbg0KYW5kIHNlbmRzIGl0IHRvIHRoZSBhcHByb3ByaWF0ZSBw bGFjZSBpbiBzeXNmcy4=
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html