linux-device-driver

P1010 MAC to Switch port direct connection without PHY

余生颓废 提交于 2020-01-02 09:55:16
问题 I have a custom board with freescale P1010 processor in which P1010's eTSEC2 ( Enhanced 3-speed Ethernet controller) port is directly connected to Marvell 88E6046 ethernet switch Port 9 in SGMII mode. Linux (3.17) DSA driver is able to probe and detect switch ( Port 9 is 'cpu' whereas port 0 and 1 are designated as 'lan1' and 'lan2'). The problem however is, that there is no PHY for switch to attach to ( 'ifconfig up' fails to attach to ethx). U-boot creates a 'generic PHY' eth0 since it

How .ko file is built

强颜欢笑 提交于 2020-01-02 08:54:22
问题 I am trying to port my own driver to a Beagle board xm arm-cortex-A8 . While porting I am trying to figuring out how the .ko file actually builds. In our Makefile we only have a command to build an .o file. How is a .ko file built? Using linux- 2.6.38.8 kernel and trying to configure my driver for my kernel. 回答1: The kernel kbuild module document has lots of information on how to build an external module. If you have Raspberian or some other embedded ARM Linux, you will need to get the source

“Unknown symbol in module” on module insertion despite EXPORT_SYMBOL

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-02 07:14:23
问题 I am trying to compile and insert the r8169 realtek ethernet driver. My kernel version is ebin@sony:~$ uname -r 4.2.0-rc3-custom I have the full source of the same in my local disk, which is used to install the current kernel. The module compiles successfully when I run make -C /lib/modules/ uname -r /build M= pwd modules but when I insert the module, it shows ebin@sony:~/linux_testing/linux-stable/drivers/net/ethernet/realtek$ sudo insmod r8169.ko insmod: ERROR: could not insert module r8169

After adding request_mem_region my driver fails every first access with “busy” message

对着背影说爱祢 提交于 2020-01-02 05:24:11
问题 OK, this is really weird to me. I've got a simulated CAN bus driver, it is a Linux Kernel module. Then I have a test application running in user space which accesses the driver via opening a file descriptor and sending ioctl() messages. Now the CAN bus driver is just something I've been adopting to run on the x86 platform (it was running on our embedded Coldfire system). On the embedded system it had to use request_mem_region() / ioremap() to get the memory I/O area accessible, I don't need

Probe problem when writing a I2C device driver

不羁岁月 提交于 2020-01-02 03:49:11
问题 I am a newbie in writing linux device driver, forgive me if anything stupid a asked and my poor English^^ I am trying to write a driver for a touch panel, which communicate with CPU via I2C. I tried to add a device driver into linux platform, and the register was success, I mean the driver was loaded, but the probe function didn't fired up!! Above is partial code of the driver i wrote. static int i2c_ts_probe(struct i2c_client *client, const struct i2c_device_id * id) { /* ... */ } static int

why is u8 u16 u32 u64 used instead of unsigned int in kernel programming

霸气de小男生 提交于 2020-01-02 00:27:05
问题 I see u8 u16 u32 u64 data types being used in kernel code. And I am wondering why is there need to use u8 or u16 or u32 or u64 and not unsigned int ? 回答1: Often when working close to the hardware or when trying to control the size/format of a data structure you need to have precise control of the size of your integers. As for u8 vs uint8_t , this is simply because Linux predated <stdint.h> being available in C, which is technically a C99-ism, but in my experience is available on most modern

Call a userspace function from within a Linux kernel module

佐手、 提交于 2020-01-01 11:44:06
问题 I'm programming a simple Linux character device driver to output data to a piece of hardware via I/O ports. I have a function which performs floating point operations to calculate the correct output for the hardware; unfortunately this means I need to keep this function in userspace since the Linux kernel doesn't handle floating point operations very nicely. Here's a pseudo representation of the setup (note that this code doesn't do anything specific, it just shows the relative layout of my

What is DMA mapping and DMA engine in context of linux kernel?

余生颓废 提交于 2020-01-01 05:11:11
问题 What is DMA mapping and DMA engine in context of linux kernel? When DMA mapping API and DMA engine API can be used in Linux Device Driver? Any real Linux Device Driver example as a reference would be great. 回答1: What is DMA mapping and DMA engine in context of linux kernel? The kernel normally uses virtual address. Functions like kmalloc() , vmalloc() normally return virtual address. It can be stored in void* . Virtual memory system converts these addresses to physical addresses. These

Do I need to “enable” a PCIe memory region in a Linux 3.12 driver?

淺唱寂寞╮ 提交于 2020-01-01 03:21:13
问题 I have code, called from the probe() function of my PCIe driver (loosely based on this post): EDIT: Based on Andreas Bombe's response, I changed the code to use pci_iomap() , but I'm still experience the system hang static my_pci_dev pci_dev; /* local structure */ static int pci_setup_region(struct pci_dev *dev) { int bar = 0; pci_dev.physical.addr = pci_resource_start(dev, bar); pci_dev.physical.size = pci_resource_len(dev, bar); pci_dev.virtual.addr = pci_iomap(dev, bar, pci_dev.physical

How can I programmatically set permissions on my char device

断了今生、忘了曾经 提交于 2020-01-01 00:44:10
问题 I've recently inherited some code at work, this is old 2.4.X linux kernel drivers and I've been tasked with getting them working on a newer kernel 2.6 or greater. I'm running on OpenSUSE 12.1 with a 3.1.10 kernel. I've updated the original code from register_chrdev() to use class_create()/device_create() calls and I can see my devices show up in /dev correctly. My current issue is that the permissions for my device are being set to r/w for user only: crw------- 1 root root 244, 0 Aug 7 07:57