summaryrefslogtreecommitdiffstats
path: root/include/driver.h
Commit message (Collapse)AuthorAgeFilesLines
* nvmem: add support for new read-only memory (rmem) bindingAhmad Fatoum2021-06-211-0/+3
| | | | | | | | | | | | | Only upstream user of this binding is the raspberry pi 4 DT, where it's used to pass along bootloader-provided info to Linux. We have instances in barebox, where a previous stage bootloader passes along a memory region with info for barebox to interpret. This could in future be modelled as nvmem-rmem nodes. The binding is also quite handy for debugging. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210619034516.6737-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* driver: add flag to check if cdev is an mci deviceMarco Felsch2021-05-121-0/+6
| | | | | | | | | | We need this during mount() to check if the cdev is an mmc/mci main|user hardware partition device. Later on we add the feature to pass "root=/dev/mmcblkXpN" as kernel command line. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20210510102523.7147-1-m.felsch@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* driver: provide dev_request_mem_resource_by_name() helperAhmad Fatoum2021-01-051-0/+5
| | | | | | | | | | | There are both dev_request_mem_resource() and dev_request_mem_region(), which return the struct resource and a IOMEM(.start) respectively. There is only dev_request_mem_region_by_name(), but no dev_request_mem_resource_by_name(), so add the latter for symmetry. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/driver-macro' into masterSascha Hauer2020-10-141-0/+6
|\
| * treewide: Use driver macroSascha Hauer2020-09-291-0/+6
| | | | | | | | | | | | | | We have several macros for a oneline driver registration. Add some missing and use them consistently where possible througout the tree. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | driver: introduce less error-prone dev_get_drvdata alternativeAhmad Fatoum2020-10-091-0/+18
|/ | | | | | | | | | | | | | | | | | | | | | | | | | We use dev_get_drvdata to get the driver match data associated with a device. This has two shortcomings: - Linux has dev_get_drvdata too, which returns a private pointer for driver specific info to associate with a device. We use dev->priv (or more often container_of) for that in barebox instead - It nearly always involves a cast to a double pointer, which is error-prone as size and alignment match need to be ensured on the programmer's part and can easily be gotten wrong: enum dev_type type; dev_get_drvdata(dev, (const void **)&type); // UB! Add a new function that instead of using a double pointer argument, returns the pointer directly: - For normal pointer driver data, no cast is necessary - For integer driver data casted to a pointer for storage, the cast is still necessary, but it's only a single pointer this way Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: remove references to CREDITSUwe Kleine-König2020-04-271-3/+0
| | | | | | | | The CREDITS file was removed from barebox in 2015 by commit 6570288f2d97 ("Remove the CREDITS file"). Remove references to it from several files. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/block'Sascha Hauer2020-03-181-0/+1
|\
| * cdev: Add discard_range hookSascha Hauer2020-02-141-0/+1
| | | | | | | | | | | | | | To pass though discard_range() to the underlying drivers add a discard_range hook to struct cdev_operations. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | include: add SPDX GPL-2.0-or-later license tags where applicableRoland Hieber2020-02-171-11/+1
|/ | | | | | Signed-off-by: Roland Hieber <rohieb@rohieb.name> Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* device: Introduce dma_offsetSascha Hauer2019-12-201-0/+2
| | | | | | | | | | For devices that do not have a 1:1 mapping between DMA and CPU we need a dma_offset. This adds dma_offset to struct device_d and starts honoring it in ARM dma_(un)map_single(). Also we add some comments to functions that would normally need a device argument to make the DMA <-> CPU translations device specific. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* driver: add missing parentheses around macro argumentAhmad Fatoum2019-12-091-2/+2
| | | | | | | | Currently, the macro can't be used for more complex expressions like &pci_dev->dev. Fix this by adding the missing parentheses. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/ubootenv'Sascha Hauer2019-06-111-0/+4
|\
| * drivers: Introduce late_platform_driver()Andrey Smirnov2019-06-071-0/+2
| | | | | | | | | | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * filetype: Allow specifying cdev's filetype explicitlyAndrey Smirnov2019-06-071-0/+2
| | | | | | | | | | | | | | | | | | Allow specifying cdev's filetype explicitly to support the cases where the type of a cdev is known apriori, yet cannot be determined by reading the cdev's content. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | driver: left shift 1U instead of 1 in bitmask for consistencyAhmad Fatoum2019-05-241-2/+2
|/ | | | | | | The first two masks use 1U already, so follow suit. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers: Drop dummy_probe()Andrey Smirnov2019-02-271-3/+0
| | | | | | | Drop dummy_probe() due to lack of users in the tree. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* include: Drop mem_memmap()Andrey Smirnov2019-02-271-1/+0
| | | | | | | Drop what looks like a leftover function prototype. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: devfs: Change .lseek callbacks to return 'int'Andrey Smirnov2019-02-041-1/+1
| | | | | | | | | | | Returning requested offset from .lseek() callback doesn't really give us any new information while bringing unnecessary complications. Change all .lseek() types (both in struct struct cdev_operations and in struct fs_driver_d) to return 'int' and adjust the rest of the codebase accordingly. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* devfs: Drop dev_lseek_default()Andrey Smirnov2019-01-291-5/+0
| | | | | | | | | | | | | | | | | | | | | Only the following cdevs do not declare an .lseek() operation: - Console devices in common/console.c - Firmware framework in common/firmware.c - JTAG driver in drivers/misc/jtag.c - UBI in drivers/mtd/ubi/barebox.c Of those four, first two are marked DEVFS_IS_CHARACTER_DEV and implement only .write() operation and the last two don't implement anything but .ioctl(). While there's probably no meaningful way to use lseek() against any of those devices, there doesn't seem to be any harm in allowing it either. Change devfs_lseek() to ignore absense of .lseek() callback and drop dev_lseek_default() and all references to it in the codebase. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/net-switch-mv88e6xxx'Sascha Hauer2018-11-091-6/+19
|\
| * drivers: base: Convert device_d name to be dynamically allocatedAndrey Smirnov2018-10-181-3/+2
| | | | | | | | | | | | | | | | Convert device_d name to be dynamically allocated in order to lift MAX_DRIVER_NAME length limit needed for commits that follow. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * base: Don't use shared buffer for results of dev_id()Andrey Smirnov2018-10-181-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Using shared memory buffer to return results of dev_id() leads to incorrect results when used as follows: dev_info(..., "... %s ...\n", ..., dev_name(foo), ...); since result returned for dev_name(foo) will be overwritten by dev_name() call that will happen as a part of dev_* logging functions. To prevent that allocate a dedicated field "unique_name" in struct device_d and use it to store unique name returned by dev_id()/dev_name(). Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * drivers: Introduce dev_set_name()Andrey Smirnov2018-10-181-3/+8
| | | | | | | | | | | | | | | | Introduce dev_set_name() in order to hide implementation details of setting device's name so it'd be easier to change it. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | drivers: base: Drop dev_get_mem_region_by_name()Andrey Smirnov2018-10-291-4/+0
|/ | | | | | | | Drop dev_get_mem_region_by_name() which doesn't seem to have any users in the codebase. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* driver: Adopt DMA mask concept from LinuxAndrey Smirnov2018-08-311-0/+2
| | | | | | | | | | In order to be able to detect cases where DMA isn't capable of reaching every memory address, port the concept of DMA mask, dma_set_mask() function and add appropriate check to dma_mapping_error(). Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* rename file_operations -> cdev_operationsSascha Hauer2018-04-061-2/+2
| | | | | | | | Linux also has struct file_operations which are something different. Rename our file_operations to cdev_operations which better matches what we have. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: add support loop mount offsetPhilipp Zabel2018-02-051-1/+1
| | | | | | | | When loop mounting, allow to specify an offset into the file, similarly to the losetup offset option. Multiplicative suffixes are supported. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* driver: Add device_detect_all() functionSascha Hauer2017-12-011-0/+1
| | | | | | | | Add a device_detect_all function to detect all devices and use it in the detect command. This makes the functionality reusable in other code. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* devfs-core: add function to find cdev by partuuidSteffen Trumtrar2017-07-101-0/+1
| | | | | Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
* fs: add cdev_create_loop and cdev_remove_loop for loop mount optionPhilipp Zabel2017-06-061-0/+2
| | | | | | | | | | | | | | | | | | | Allow to create a loopback cdev from a file. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Fixed up with: fs: Makefile: Add parseopt to all builds parseopt.h was included to fs.c with commit 9248b, but parseopt.o has a dependency to CONFIG_FS_NFS. Moved parseopt.o to the default build to eliminate build failures. Signed-off-by: Daniel Schultz <d.schultz@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* cdev: make file operations constPhilipp Zabel2017-06-011-1/+1
| | | | | | | | | | | | | | scripts/checkpatch.pl warns that struct file_operations should be const, but cdev->ops is not const, so without this patch we can choose between a warning from checkpatch and a warning from the compiler about discarding the const attribute when assigning the struct file_operations cdev->ops. Since there is no reason to modify the contents of cdev->ops after probing, make it const. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: Create automount entries for the default mount pathesSascha Hauer2017-05-101-0/+8
| | | | | | | | | | In barebox the default mount path for a cdev is /mnt/<cdevname> which can be mounted with "mount <cdevname>" without specifying a target path explicitly. Simplify this further by creating automount entries for the default mount pathes which makes a manual mount completely unnecessary. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* of: partitions: flag partitions from a partition tableSascha Hauer2017-03-311-0/+1
| | | | | | | | | We are going to call the of_partition_fixup for regular block devices like MMC/SD aswell. Add a flag to partitions indicating they are instanciated from a on-disk partition table so that they won't be added as device tree partitions during fixup. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: devfs-core: replace DEVFS_IS_PARTITION flag with pointer to the master cdevSascha Hauer2017-03-311-1/+1
| | | | | | | | Instead of having a flag indicating a cdev is a partition on some master cdev, just add a master pointer to the cdev, so that we can also find out who the master is. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* cdev: Collect partitions on listSascha Hauer2017-03-311-0/+1
| | | | | | | We currently do not have a way to iterate over all partitions of a cdev. Change this. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* devfs: Add optional truncate callback for device filesTeresa Remmet2017-01-111-0/+1
| | | | | | | | Not all device files have trivial fix device sizes like static ubi volumes. Here the device file size equals the image size it contains. Signed-off-by: Teresa Remmet <t.remmet@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/mtd'Sascha Hauer2016-03-111-2/+2
|\
| * mtd: Fix erasing of devices >4GiBSascha Hauer2016-02-091-2/+2
| | | | | | | | | | | | | | | | | | When a device >4GiB is erased, not only the offset can be bigger than 4GiB, but also the size. This happens with the simplest command to erase a device: erase /dev/nand0. Make the size argument a 64bit type to make this work. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | driver: Introduce dev_request_mem_resourceSascha Hauer2016-02-231-0/+6
|/ | | | | | | | | | | | dev_request_mem_region returns a void * which shall be checked with IS_ERR(), but in some cases the valid pointer returned clashes with error values. This is especially the case on some Atmel SoCs. This introduces dev_request_mem_resource which returns a struct resource instead which in any case can be checked with IS_ERR(). It's the drivers responsibility then to get the IOMEM pointer from the resource. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* devfs: Add symlink supportSascha Hauer2016-01-081-0/+5
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* cdev: Add function to find cdev by device_nodeSascha Hauer2015-09-011-0/+2
| | | | | | | | | | This adds a device_node member to struct cdev and a function to find a cdev by device_node. This also removes the setting of cdev->dev->device_node in the of partition parser. We must not set the device since it may not refer to a partition but to a whole device with partitions. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* exitcall: move device_shutdown to exitcall infrastructureHerve Codina2015-07-131-5/+0
| | | | | Signed-off-by: Herve Codina <Herve.CODINA@celad.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* cdev: Add partuuid string to struct cdevSascha Hauer2015-06-181-0/+3
| | | | | | | | This adds the partuuid string to struct cdev in order to have this available for constructing a suitable Linux root=PARTUUID= option for booting Linux. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/of-device-id'Sascha Hauer2015-05-061-1/+1
|\
| * of: use 'const void *' for struct of_device_id.dataAntony Pavlov2015-04-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since 2011 barebox' of_device_id struct uses unsigned long type for data field: struct of_device_id { char *compatible; unsigned long data; }; Almost always struct of_device_id.data field are used as pointer and need 'unsigned long' casting. E.g. see 'git grep -A 4 of_device_id drivers/' output: drivers/ata/sata-imx.c:static __maybe_unused struct of_device_id imx_sata_dt_ids[] = { drivers/ata/sata-imx.c- { drivers/ata/sata-imx.c- .compatible = "fsl,imx6q-ahci", drivers/ata/sata-imx.c- .data = (unsigned long)&data_imx6, drivers/ata/sata-imx.c- }, { Here is of_device_id struct in linux kernel v4.0: struct of_device_id { char name[32]; char type[32]; char compatible[128]; const void *data; }; Changing of_device_id.data type to 'const void *data' will increase barebox' linux kernel compatibility and decrease number of 'unsigned long' casts. Part of the patch was done using the 'coccinelle' tool with the following semantic patch: @rule1@ identifier dev; identifier type; identifier func; @@ func(...) { <... - dev_get_drvdata(dev, (unsigned long *)&type) + dev_get_drvdata(dev, (const void **)&type) ...> } @rule2@ identifier dev; identifier type; identifier func; identifier data; @@ func(...) { <... - dev_get_drvdata(dev, (unsigned long *)&type->data) + dev_get_drvdata(dev, (const void **)&type->data) ...> } Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | drivers/base: Mark (of|platform)_device_id data as constantUwe Kleine-König2015-04-171-3/+3
|/ | | | | | | | | | There should be no reason to ever change the data pointed to by id_table or of_compatible. So make this offical by adding some 'const's. In Linux the corresponding pointers are marked as const, too. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers: remove unused function dev_protect()Marc Kleine-Budde2015-03-031-2/+0
| | | | | Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* driver: add postcore_platform_driverJean-Christophe PLAGNIOL-VILLARD2015-02-041-0/+2
| | | | | Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* driver: workaroud resource request that conflicts with errno PTRJean-Christophe PLAGNIOL-VILLARD2015-01-081-0/+8
| | | | | | | | | | | | | | | | broken since commit ed6e965824303255cacc1c1a195d3684caa26bce Author: Sascha Hauer <s.hauer@pengutronix.de> resource: Let dev_request_mem_region return an error pointer Introduce dev_request_mem_region_err_null only used on platform like at91 where the resource address conflicts with errno PTR. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>