### Configure PON Device Tree Example Source: https://github.com/william24hmar/android_kernel_nothing_sm7325/blob/lineage-23.0/arch/arm64/boot/dts/vendor/bindings/input/qpnp-power-on.txt Complete device tree configuration example demonstrating PON peripheral setup with KPDPWR and RESIN sources, including interrupt mapping, timing parameters, and reset configurations. ```device-tree qcom,power-on@800 { compatible = "qcom,qpnp-power-on"; reg = <0x800>; interrupts = <0x0 0x8 0x0 IRQ_TYPE_EDGE_BOTH>, <0x0 0x8 0x1 IRQ_TYPE_EDGE_BOTH>, <0x0 0x8 0x4 IRQ_TYPE_EDGE_RISING>, <0x0 0x8 0x5 IRQ_TYPE_EDGE_RISING>; interrupt-names = "kpdpwr", "resin", "resin-bark", "kpdpwr-resin-bark"; qcom,pon-dbc-delay = <15625>; qcom,system-reset; qcom,s3-debounce = <32>; qcom,s3-src = "resin"; qcom,clear-warm-reset; qcom,store-hard-reset-reason; qcom,pon_1 { qcom,pon-type = ; qcom,pull-up; linux,code = ; }; qcom,pon_2 { qcom,pon-type = ; qcom,support-reset = <1>; qcom,pull-up; qcom,s1-timer = <0>; qcom,s2-timer = <2000>; qcom,s2-type = ; }; ``` -------------------------------- ### Qualcomm GLINK RPM Edge Configuration Example Source: https://github.com/william24hmar/android_kernel_nothing_sm7325/blob/lineage-23.0/arch/arm64/boot/dts/vendor/bindings/soc/qcom/qcom,glink.txt Example configuration for a GLINK RPM edge on an MSM8996 device, including mailbox and memory resource definitions, and RPM requests channel setup. ```dts apcs_glb: mailbox@9820000 { compatible = "qcom,msm8996-apcs-hmss-global"; reg = <0x9820000 0x1000>; #mbox-cells = <1>; }; rpm_msg_ram: memory@68000 { compatible = "qcom,rpm-msg-ram"; reg = <0x68000 0x6000>; }; rpm-glink { compatible = "qcom,glink-rpm"; interrupts = ; qcom,rpm-msg-ram = <&rpm_msg_ram>; mboxes = <&apcs_glb 0>; rpm-requests { compatible = "qcom,rpm-msm8996"; qcom,glink-channels = "rpm_requests"; qcom,intents = <0x400 5 0x800 1>; ... }; }; ``` -------------------------------- ### Clone Linux Kernel Mainline Repository using Git Source: https://github.com/william24hmar/android_kernel_nothing_sm7325/blob/lineage-23.0/Documentation/process/submitting-patches.rst This command is used to obtain a local copy of the current Linux kernel mainline source tree. It requires Git to be installed and accessible. The output is the cloned repository. ```bash git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git ``` -------------------------------- ### Platform callbacks (setup) (C) Source: https://github.com/william24hmar/android_kernel_nothing_sm7325/blob/lineage-23.0/Documentation/fb/ep93xx-fb.rst Optional platform callbacks can be used for board-specific setup, teardown, and blanking. The setup function is called when the framebuffer driver is installed. ```c static int some_board_fb_setup(struct platform_device *pdev) { struct ep93xxfb_mach_info *mach_info = pdev->dev.platform_data; struct fb_info *fb_info = platform_get_drvdata(pdev); /* Board specific framebuffer setup */ } ``` -------------------------------- ### Full IIO provider and consumer configuration example in Device Tree Source: https://github.com/william24hmar/android_kernel_nothing_sm7325/blob/lineage-23.0/arch/arm64/boot/dts/vendor/bindings/iio/iio-bindings.txt Comprehensive example combining a provider definition, an iio-hwmon consumer with multiple channel references, and an additional consumer with named channels. Demonstrates end‑to‑end wiring of IIO devices. ```Device Tree adc: max1139@35 { compatible = "maxim,max1139"; reg = <0x35>; #io-channel-cells = <1>; }; iio-hwmon { compatible = "iio-hwmon"; io-channels = <&adc 0>, <&adc 1>, <&adc 2>, <&adc 3>, <&adc 4>, <&adc 5>, <&adc 6>, <&adc 7>, <&adc 8>, <&adc 9>; }; some_consumer { compatible = "some-consumer"; io-channels = <&adc 10>, <&adc 11>; io-channel-names = "adc1", "adc2"; }; ``` -------------------------------- ### RAVE SP Device Tree Configuration Example Source: https://github.com/william24hmar/android_kernel_nothing_sm7325/blob/lineage-23.0/arch/arm64/boot/dts/vendor/bindings/mfd/zii,rave-sp.txt Device tree configuration example showing RAVE Supervisory Processor setup with compatible string, UART baud rate, and watchdog sub-device. Demonstrates proper hierarchical structure with parent UART controller and child sub-devices. Requires compatible property from supported variants and current-speed property for UART communication. ```Device Tree rdu { compatible = "zii,rave-sp-rdu2"; current-speed = <1000000>; watchdog { compatible = "zii,rave-sp-watchdog"; }; }; ``` -------------------------------- ### seq_file Iterator Start Function Example in C Source: https://github.com/william24hmar/android_kernel_nothing_sm7325/blob/lineage-23.0/Documentation/filesystems/seq_file.txt An example of the `start()` function for a seq_file iterator. This function initializes the iterator, allocating memory for its position and setting it based on the provided `pos` argument. It returns a pointer to the iterator's private data. ```c #include #include // ... other code ... static void *ct_seq_start(struct seq_file *s, loff_t *pos) { loff_t *spos = kmalloc(sizeof(loff_t), GFP_KERNEL); if (! spos) return NULL; *spos = *pos; return spos; } ``` -------------------------------- ### GPIO Decoder Device Tree Configuration Example Source: https://github.com/william24hmar/android_kernel_nothing_sm7325/blob/lineage-23.0/arch/arm64/boot/dts/vendor/bindings/input/gpio-decoder.txt Device Tree binding example showing complete GPIO decoder configuration including required compatible property, GPIO specifiers with MSB-first ordering, optional maximum value setting, and axis mapping for input subsystem integration. ```Device Tree gpio-decoder0 { compatible = "gpio-decoder"; gpios = <&pca9536 3 GPIO_ACTIVE_HIGH>, <&pca9536 2 GPIO_ACTIVE_HIGH>, <&pca9536 1 GPIO_ACTIVE_HIGH>, <&pca9536 0 GPIO_ACTIVE_HIGH>; linux,axis = <0>; /* ABS_X */ decoder-max-value = <9>; }; ``` -------------------------------- ### Device Node Example (CPU) Source: https://github.com/william24hmar/android_kernel_nothing_sm7325/blob/lineage-23.0/arch/arm64/boot/dts/vendor/bindings/opp/ti-omap5-opp-supply.txt Illustrates the device node configuration for a CPU, including connections to the VDD and VBB supplies using phandles. ```device tree cpus { cpu0: cpu@0 { device_type = "cpu"; ... vdd-supply = <&vcc>; vbb-supply = <&abb_mpu>; }; }; ``` -------------------------------- ### Board Setup Example for Renesas R-Car Gen2 Platforms (Composite Video Input) Source: https://github.com/william24hmar/android_kernel_nothing_sm7325/blob/lineage-23.0/arch/arm64/boot/dts/vendor/bindings/media/renesas,vin.txt This example demonstrates a board setup configuration for a composite video input using the rcar_vin driver on Gen2 platforms. It configures an I2C bus and an ADV7180 video decoder chip connected to it. ```dts &i2c2 { status = "okay"; pinctrl-0 = <&i2c2_pins>; pinctrl-names = "default"; adv7180@20 { ``` -------------------------------- ### VFIO Device Information and Region/IRQ Setup in C Source: https://github.com/william24hmar/android_kernel_nothing_sm7325/blob/lineage-23.0/Documentation/driver-api/vfio.rst This snippet retrieves device information using VFIO_DEVICE_GET_INFO, iterates over regions to get details via VFIO_DEVICE_GET_REGION_INFO for mapping setup, handles IRQs with VFIO_DEVICE_GET_IRQ_INFO for eventfd configuration, and performs a device reset with VFIO_DEVICE_RESET. It depends on VFIO headers and a valid file descriptor for the device. Inputs are ioctl commands and structures; outputs include populated info structs for further device access. Limitations include platform-specific region behaviors, especially for PCI config space. ```C ioctl(device, VFIO_DEVICE_GET_INFO, &device_info); for (i = 0; i < device_info.num_regions; i++) { struct vfio_region_info reg = { .argsz = sizeof(reg) }; reg.index = i; ioctl(device, VFIO_DEVICE_GET_REGION_INFO, ®); /* Setup mappings... read/write offsets, mmaps * For PCI devices, config space is a region */ } for (i = 0; i < device_info.num_irqs; i++) { struct vfio_irq_info irq = { .argsz = sizeof(irq) }; irq.index = i; ioctl(device, VFIO_DEVICE_GET_IRQ_INFO, &irq); /* Setup IRQs... eventfds, VFIO_DEVICE_SET_IRQS */ } /* Gratuitous device reset and go... */ ioctl(device, VFIO_DEVICE_RESET); ``` -------------------------------- ### Example GPIO Configuration Source: https://github.com/william24hmar/android_kernel_nothing_sm7325/blob/lineage-23.0/arch/arm64/boot/dts/vendor/bindings/pinctrl/qcom,pmic-gpio.txt An example showing the use of multiple property settings for volume keys including `input-enable`, `bias-pull-up`, `drive-push-pull`, `qcom,drive-strength`, and `power-source`. ```YAML volume-keys { pins = "gpio20", "gpio21"; function = "normal"; input-enable; bias-pull-up; drive-push-pull; qcom,drive-strength = ; power-source = ; }; ``` -------------------------------- ### Compile and Install MXSER Driver Source: https://github.com/william24hmar/android_kernel_nothing_sm7325/blob/lineage-23.0/Documentation/driver-api/serial/moxa-smartio.rst Cleans previous builds and compiles the modified MXSER driver source code. Installs the newly built driver module into the kernel. Must be executed from the driver directory after making source modifications. ```bash make clean; make install ``` -------------------------------- ### SMB5 Charger Example Configuration Source: https://github.com/william24hmar/android_kernel_nothing_sm7325/blob/lineage-23.0/arch/arm64/boot/dts/vendor/bindings/power/supply/qcom/qpnp-smb5.txt An example configuration for the SMB5 charger, showing how to set up the compatible string, address cells, size cells, and various IO channels. Includes a nested node for the charger and OTG peripherals with their respective registers and interrupts. ```Device Tree pm8150b_charger: qcom,qpnp-smb5 { compatible = "qcom,qpnp-smb5"; #address-cells = <1>; #size-cells = <1>; #io-channel-cells = <1>; dpdm-supply = <&qusb_phy0>; qcom,sec-charger-config = <1>; io-channels = <&pm8150b_vadc ADC_USB_IN_V_16>, <&pm8150b_vadc ADC_USB_IN_I>, <&pm8150b_vadc ADC_CHG_TEMP>, <&pm7250b_qg PSY_IIO_RESISTANCE_ID>, <&pm7250b_qg PSY_IIO_CHARGE_COUNTER>, <&pm7250b_qg PSY_IIO_CHARGE_FULL>; io-channel-names = "usb_in_voltage", "usb_in_current", "chg_temp", "resistance_id", "charge_counter", "charge_full"; qcom,chgr@1000 { reg = <0x1000 0x100>; interrupts = <0x2 0x10 0x0 IRQ_TYPE_NONE>, <0x2 0x10 0x1 IRQ_TYPE_NONE>, <0x2 0x10 0x2 IRQ_TYPE_NONE>, <0x2 0x10 0x3 IRQ_TYPE_NONE>, <0x2 0x10 0x4 IRQ_TYPE_NONE>; interrupt-names = "chg-error", "chg-state-change", "step-chg-state-change", "step-chg-soc-update-fail", "step-chg-soc-update-request"; }; qcom,otg@1100 { reg = <0x1100 0x100>; interrupts = <0x2 0x11 0x0 IRQ_TYPE_NONE>; ``` -------------------------------- ### Generate Patch for a Single File using diff -up Source: https://github.com/william24hmar/android_kernel_nothing_sm7325/blob/lineage-23.0/Documentation/process/submitting-patches.rst This example demonstrates how to create a patch file for a single source file. It involves copying the original file, making modifications, and then using the `diff -up` command to generate a unified diff. This is useful if not using Git. Dependencies: `vi` or another text editor, `diff` command. ```bash SRCTREE=linux MYFILE=drivers/net/mydriver.c cd $SRCTREE cp $MYFILE $MYFILE.orig vi $MYFILE # make your change cd .. diff -up $SRCTREE/$MYFILE{.orig,} > /tmp/patch ``` -------------------------------- ### GENI Serial Engine Device Example Source: https://github.com/william24hmar/android_kernel_nothing_sm7325/blob/lineage-23.0/arch/arm64/boot/dts/vendor/bindings/platform/msm/qcom-geni-se.txt Provides an example device tree node configuration for the GENI Serial Engine Driver. This includes required and optional properties to configure the driver. ```dts qupv3_0: qcom,qupv3_0_geni_se@8c0000 { compatible = "qcom,qupv3-geni-se"; reg = <0x8c0000 0x6000>; qcom,bus-mas-id = <100>; qcom,bus-slv-id = <300>; iommu_qupv3_0_geni_se_cb: qcom,iommu_qupv3_0_geni_se_cb { compatible = "qcom,qupv3-geni-se-cb"; iommus = <&apps_smmu 0x1 0x0>; }; } ``` -------------------------------- ### Device Tree Configuration Example for Cygnus IOMUX Source: https://github.com/william24hmar/android_kernel_nothing_sm7325/blob/lineage-23.0/arch/arm64/boot/dts/vendor/bindings/pinctrl/brcm,cygnus-pinmux.txt This code snippet demonstrates a typical device tree configuration for the Broadcom Cygnus IOMUX controller. It specifies the compatible device, register address and size, and configures the 'i2s0' function using specific groups. This example is crucial for setting up peripherals that rely on the IOMUX controller. ```devicetree pinmux: pinmux@0301d0c8 { compatible = "brcm,cygnus-pinmux"; reg = <0x0301d0c8 0x1b0>; pinctrl-names = "default"; pinctrl-0 = <&i2s0_default>; i2s0_default: i2s0_default { mux { function = "i2s0"; groups = "i2s0_0_grp", "i2s0_1_grp"; }; }; }; ``` -------------------------------- ### Memory-Mapped Buffer Fetch Loop (C Pseudo-Code) Source: https://github.com/william24hmar/android_kernel_nothing_sm7325/blob/lineage-23.0/Documentation/usb/usbmon.rst Pseudo-code example for looping to fetch and process USB events from mmap-ed /dev/usbmon buffer using MON_IOCX_MFETCH. Initializes fetch args, performs ioctl to get offsets, then processes headers and data. Handles filler packets; depends on prior mmap setup. Limitation: requires non-blocking open for wait behavior; errors need handling. ```C struct mon_mfetch_arg fetch; struct usbmon_packet *hdr; int nflush = 0; for (;;) { fetch.offvec = vec; // Has N 32-bit words fetch.nfetch = N; // Or less than N fetch.nflush = nflush; ioctl(fd, MON_IOCX_MFETCH, &fetch); // Process errors, too nflush = fetch.nfetch; // This many packets to flush when done for (i = 0; i < nflush; i++) { hdr = (struct ubsmon_packet *) &mmap_area[vec[i]]; if (hdr->type == '@') // Filler packet continue; caddr_t data = &mmap_area[vec[i]] + 64; ``` -------------------------------- ### Q6AFE Device Tree Configuration Example Source: https://github.com/william24hmar/android_kernel_nothing_sm7325/blob/lineage-23.0/arch/arm64/boot/dts/vendor/bindings/sound/qcom,q6afe.txt Complete device tree configuration example showing Q6AFE node with DAI subnodes for HDMI, TDM, and MI2S interfaces. Demonstrates proper compatible strings, register assignments, and interface-specific properties. Includes configuration for primary, secondary, tertiary, and quaternary MI2S interfaces as well as TDM synchronization parameters. ```Device Tree q6afe@4 { compatible = "qcom,q6afe"; reg = ; dais { compatible = "qcom,q6afe-dais"; #sound-dai-cells = <1>; #address-cells = <1>; #size-cells = <0>; hdmi@1 { reg = <1>; }; tdm@24 { reg = <24>; qcom,tdm-sync-mode = <1>: qcom,tdm-sync-src = <1>; qcom,tdm-data-out = <0>; qcom,tdm-invert-sync = <1>; qcom,tdm-data-delay = <1>; qcom,tdm-data-align = <0>; }; tdm@25 { reg = <25>; qcom,tdm-sync-mode = <1>: qcom,tdm-sync-src = <1>; qcom,tdm-data-out = <0>; qcom,tdm-invert-sync = <1>; qcom,tdm-data-delay <1>: qcom,tdm-data-align = <0>; }; prim-mi2s-rx@16 { reg = <16>; qcom,sd-lines = <0 2>; }; prim-mi2s-tx@17 { reg = <17>; qcom,sd-lines = <1>; }; sec-mi2s-rx@18 { reg = <18>; qcom,sd-lines = <0 3>; }; sec-mi2s-tx@19 { reg = <19>; qcom,sd-lines = <1>; }; tert-mi2s-rx@20 { reg = <20>; qcom,sd-lines = <1 3>; }; tert-mi2s-tx@21 { reg = <21>; qcom,sd-lines = <0>; }; quat-mi2s-rx@22 { reg = <22>; qcom,sd-lines = <0>; }; quat-mi2s-tx@23 { reg = <23>; qcom,sd-lines = <1>; }; }; }; ``` -------------------------------- ### QPNP PBS Device Tree Node Example Source: https://github.com/william24hmar/android_kernel_nothing_sm7325/blob/lineage-23.0/arch/arm64/boot/dts/vendor/bindings/soc/qcom/qpnp-pbs.txt This example demonstrates the required structure for a QPNP PBS node in a Device Tree configuration. It includes the mandatory 'compatible' and 'reg' properties. ```dts pm660l_pbs: qcom,pbs@7300 { compatible = "qcom,qpnp-pbs"; reg = <0x7300 0x100>; }; ``` -------------------------------- ### Device Tree Example: Atmel ISI Configuration Source: https://github.com/william24hmar/android_kernel_nothing_sm7325/blob/lineage-23.0/arch/arm64/boot/dts/vendor/bindings/media/atmel-isi.txt This example showcases a complete ISI configuration within a device tree, including its properties and endpoint setup for communication with a camera. ```Device Tree isi: isi@f0034000 { compatible = "atmel,at91sam9g45-isi"; reg = <0xf0034000 0x4000>; interrupts = <37 IRQ_TYPE_LEVEL_HIGH 5>; pinctrl-names = "default"; pinctrl-0 = <&pinctrl_isi_data_0_7>; clocks = <&isi_clk>; clock-names = "isi_clk"; port { isi_0: endpoint { remote-endpoint = <&ov2640_0>; bus-width = <8>; vsync-active = <1>; hsync-active = <1>; }; }; }; i2c1: i2c@f0018000 { ov2640: camera@30 { compatible = "ovti,ov2640"; reg = <0x30>; pinctrl-names = "default"; pinctrl-0 = <&pinctrl_pck0_as_isi_mck &pinctrl_sensor_power &pinctrl_sensor_reset>; resetb-gpios = <&pioE 11 GPIO_ACTIVE_LOW>; pwdn-gpios = <&pioE 13 GPIO_ACTIVE_HIGH>; clocks = <&pck0>; clock-names = "xvclk"; assigned-clocks = <&pck0>; assigned-clock-rates = <25000000>; port { ov2640_0: endpoint { remote-endpoint = <&isi_0>; bus-width = <8>; }; }; }; }; ``` -------------------------------- ### CX2341X_ENC_SET_ASPECT_RATIO Source: https://github.com/william24hmar/android_kernel_nothing_sm7325/blob/lineage-23.0/Documentation/media/v4l-drivers/cx2341x.rst Sets the encoding aspect ratio. Changes take effect at the start of the next GOP. ```APIDOC ## CX2341X_ENC_SET_ASPECT_RATIO ### Description Sets the encoding aspect ratio. The change takes effect at the start of the next GOP. ### Method IOCTL ### Endpoint CX2341X_ENC_SET_ASPECT_RATIO (Enum: 153/0x99) ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - **Param[0]** (integer) - Required - Aspect ratio identifier: - 0000 = Forbidden - 0001 = 1:1 square - 0010 = 4:3 - 0011 = 16:9 - 0100 = 2.21:1 - 0101 to 1111 = Reserved ### Request Example { "Param[0]": 3 } ### Response #### Success Response (0) - **Return** (integer) - 0 on success, negative errno on failure #### Response Example { "Return": 0 } ``` -------------------------------- ### GPIO and Interrupt Controller Example Source: https://github.com/william24hmar/android_kernel_nothing_sm7325/blob/lineage-23.0/arch/arm64/boot/dts/vendor/bindings/pinctrl/allwinner,sunxi-pinctrl.txt Example configuration for a GPIO and interrupt controller using the Allwinner A1X Pin Controller, showing interrupt and GPIO properties. ```Device Tree xio: gpio@38 { compatible = "nxp,pcf8574a"; reg = <0x38>; gpio-controller; #gpio-cells = <2>; interrupt-parent = <&pio>; interrupts = <6 0 IRQ_TYPE_EDGE_FALLING>; interrupt-controller; #interrupt-cells = <2>; }; ``` -------------------------------- ### Multiple-Master IOMMU Configuration Example Source: https://github.com/william24hmar/android_kernel_nothing_sm7325/blob/lineage-23.0/arch/arm64/boot/dts/vendor/bindings/iommu/iommu.txt Example of a multiple-master IOMMU configuration in a device tree. This setup implies that masters are statically associated with the IOMMU and share address translations, as the IOMMU lacks sufficient information to differentiate between masters. ```device-tree /* multiple-master IOMMU */ iommu { /* * Masters are statically associated with this IOMMU and share * the same address translations because the IOMMU does not * have sufficient information to distinguish between masters. * ``` -------------------------------- ### Lochnagar Device Tree Example Source: https://github.com/william24hmar/android_kernel_nothing_sm7325/blob/lineage-23.0/arch/arm64/boot/dts/vendor/bindings/mfd/cirrus,lochnagar.txt Example device tree configuration for a Lochnagar2 board, including compatible strings, I2C address, GPIO settings, and sub-node bindings for clock, pinctrl, sound card, and hardware monitor components. ```Device Tree lochnagar: lochnagar@22 { compatible = "cirrus,lochnagar2"; reg = <0x22>; reset-gpios = <&gpio0 55 0>; present-gpios = <&gpio0 60 0>; lochnagar-clk { compatible = "cirrus,lochnagar2-clk"; ... }; lochnagar-pinctrl { compatible = "cirrus,lochnagar-pinctrl"; ... }; lochnagar-sc { compatible = "cirrus,lochnagar2-soundcard"; ... }; lochnagar-hwmon { compatible = "cirrus,lochnagar2-hwmon"; ... }; }; ``` -------------------------------- ### Mikroe-PROTO Audio Board Device Tree Example Source: https://github.com/william24hmar/android_kernel_nothing_sm7325/blob/lineage-23.0/arch/arm64/boot/dts/vendor/bindings/sound/mikroe,mikroe-proto.txt This is an example of a device tree node for the Mikroe-PROTO audio board. It specifies the compatible device, model name, I2S controller, audio codec, and data format. Ensure that the 'bitclock-master' and 'frame-master' properties are consistent if used. ```dts sound { compatible = "mikroe,mikroe-proto"; model = "wm8731 @ sama5d2_xplained"; i2s-controller = <&i2s0>; audio-codec = <&wm8731>; dai-format = "i2s"; }; ``` -------------------------------- ### Device Tree Example: gemtraceclk Source: https://github.com/william24hmar/android_kernel_nothing_sm7325/blob/lineage-23.0/arch/arm64/boot/dts/vendor/bindings/clock/keystone-pll.txt This example presents a device tree node configuration for the gemtraceclk, demonstrating the setup of a divider clock with bit-shift and bit-mask properties. The configuration utilizes device tree syntax for defining clock resources. ```device-tree gemtraceclk: gemtraceclk@2310120 { #clock-cells = <0>; compatible = "ti,keystone,pll-divider-clock"; clocks = <&mainmuxclk>; reg = <0x02310120 4>; bit-shift = <0>; bit-mask = <8>; clock-output-names = "gemtraceclk"; }; ``` -------------------------------- ### PWM Backlight Basic Configuration Example Source: https://github.com/william24hmar/android_kernel_nothing_sm7325/blob/lineage-23.0/arch/arm64/boot/dts/vendor/bindings/leds/backlight/pwm-backlight.txt This example demonstrates the basic configuration for a pwm-backlight device. It specifies the compatible driver, PWM channel and period, a list of brightness levels with a default index, the power supply regulator, and an enable GPIO. Optional delays for PWM on/off are also included. ```dts backlight { compatible = "pwm-backlight"; pwms = <&pwm 0 5000000>; brightness-levels = <0 4 8 16 32 64 128 255>; default-brightness-level = <6>; power-supply = <&vdd_bl_reg>; enable-gpios = <&gpio 58 0>; post-pwm-on-delay-ms = <10>; pwm-off-delay-ms = <10>; }; ``` -------------------------------- ### Run Control LED Configuration Example Source: https://github.com/william24hmar/android_kernel_nothing_sm7325/blob/lineage-23.0/arch/arm64/boot/dts/vendor/bindings/leds/leds-gpio.txt This example shows the configuration for run control LEDs, specifying their GPIOs, colors (red and green), and initial states (off and on). ```Device Tree run-control { compatible = "gpio-leds"; led0 { gpios = <&mpc8572 6 GPIO_ACTIVE_HIGH>; color = ; default-state = "off"; }; led1 { gpios = <&mpc8572 7 GPIO_ACTIVE_HIGH>; color = ; default-state = "on"; }; }; ``` -------------------------------- ### Start V4L2 Video Capture Buffers Source: https://github.com/william24hmar/android_kernel_nothing_sm7325/blob/lineage-23.0/Documentation/media/uapi/v4l/capture.c.rst Initializes video capture buffers and starts streaming using VIDIOC_QBUF and VIDIOC_STREAMON ioctls. Handles both MMAP and USERPTR memory methods. Requires pre-configured buffers and file descriptor. ```c static void start_capturing(void) { unsigned int i; enum v4l2_buf_type type; switch (io) { case IO_METHOD_READ: /* Nothing to do. */ break; case IO_METHOD_MMAP: for (i = 0; i < n_buffers; ++i) { struct v4l2_buffer buf; CLEAR(buf); buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; buf.memory = V4L2_MEMORY_MMAP; buf.index = i; if (-1 == xioctl(fd, VIDIOC_QBUF, &buf)) errno_exit("VIDIOC_QBUF"); } type = V4L2_BUF_TYPE_VIDEO_CAPTURE; if (-1 == xioctl(fd, VIDIOC_STREAMON, &type)) errno_exit("VIDIOC_STREAMON"); break; case IO_METHOD_USERPTR: for (i = 0; i < n_buffers; ++i) { struct v4l2_buffer buf; CLEAR(buf); buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; buf.memory = V4L2_MEMORY_USERPTR; buf.index = i; buf.m.userptr = (unsigned long)buffers[i].start; buf.length = buffers[i].length; if (-1 == xioctl(fd, VIDIOC_QBUF, &buf)) errno_exit("VIDIOC_QBUF"); } type = V4L2_BUF_TYPE_VIDEO_CAPTURE; if (-1 == xioctl(fd, VIDIOC_STREAMON, &type)) errno_exit("VIDIOC_STREAMON"); break; } } ``` -------------------------------- ### eBPF Register State Tracking Example Source: https://github.com/william24hmar/android_kernel_nothing_sm7325/blob/lineage-23.0/Documentation/networking/filter.txt This snippet illustrates a common scenario in eBPF verification where a register ('R2') is checked for readability at the start of a program. If the register has not been written to, the verifier will reject the program to prevent undefined behavior. ```bpf bpf_mov R0 = R2 bpf_exit ``` -------------------------------- ### CS42L42 Device Tree Binding Example Source: https://github.com/william24hmar/android_kernel_nothing_sm7325/blob/lineage-23.0/arch/arm64/boot/dts/vendor/bindings/sound/cs42l42.txt Example device tree configuration for the CS42L42 audio CODEC, including required power supplies, interrupts, and optional properties for debounce and bias levels. ```Device Tree cs42l42: cs42l42@48 { compatible = "cirrus,cs42l42"; reg = <0x48>; VA-supply = <&dummy_vreg>; VP-supply = <&dummy_vreg>; VCP-supply = <&dummy_vreg>; VD_FILT-supply = <&dummy_vreg>; VL-supply = <&dummy_vreg>; reset-gpios = <&axi_gpio_0 1 0>; interrupt-parent = <&gpio0>; interrupts = <55 8>; cirrus,ts-inv = <0x00>; cirrus,ts-dbnc-rise = <0x05>; cirrus,ts-dbnc-fall = <0x00>; cirrus,btn-det-init-dbnce = <100>; cirrus,btn-det-event-dbnce = <10>; cirrus,bias-lvls = <0x0F 0x08 0x04 0x01>; cirrus,hs-bias-ramp-rate = <0x02>; }; ``` -------------------------------- ### Device Tree PWM User Node Example Source: https://github.com/william24hmar/android_kernel_nothing_sm7325/blob/lineage-23.0/arch/arm64/boot/dts/vendor/bindings/pwm/pwm.txt This example demonstrates how a backlight device (bl) can specify its PWM configuration using the 'pwms' and 'pwm-names' properties. It shows a basic setup and an optional configuration with inverted polarity. ```device-tree pwm: pwm { #pwm-cells = <2>; }; bl: backlight { pwms = <&pwm 0 5000000>; pwm-names = "backlight"; }; bl: backlight { pwms = <&pwm 0 5000000 PWM_POLARITY_INVERTED>; pwm-names = "backlight"; }; ``` -------------------------------- ### Regulator Proxy Consumer Example - Device Tree Source: https://github.com/william24hmar/android_kernel_nothing_sm7325/blob/lineage-23.0/arch/arm64/boot/dts/vendor/bindings/regulator/proxy-consumer.txt Example of a regulator proxy consumer configuration in a device tree. It demonstrates enabling a regulator during boot with specified voltage and current constraints. ```Device Tree foo_vreg: regulator@0 { regulator-name = "foo"; regulator-min-microvolt = <1000000>; regulator-max-microvolt = <2000000>; proxy-supply = <&foo_vreg>; qcom,proxy-consumer-voltage = <1500000 2000000>; qcom,proxy-consumer-current = <25000>; qcom,proxy-consumer-enable; }; ``` ```Device Tree pmic { compatible = "foo_pmic"; ldo1-proxy-supply = <&ldo1>; ldo2-proxy-supply = <&ldo2>; ldo1: ldo1 { regulator-name = "ldo1"; regulator-min-microvolt = <1000000>; regulator-max-microvolt = <2000000>; qcom,proxy-consumer-name = "ldo1-proxy"; qcom,proxy-consumer-voltage = <1500000 2000000>; qcom,proxy-consumer-current = <25000>; qcom,proxy-consumer-enable; }; ldo2: ldo2 { regulator-name = "ldo2"; regulator-min-microvolt = <2000000>; regulator-max-microvolt = <3000000>; qcom,proxy-consumer-name = "ldo2-proxy"; qcom,proxy-consumer-voltage = <2500000 3000000>; qcom,proxy-consumer-current = <50000>; qcom,proxy-consumer-enable; }; }; ``` -------------------------------- ### Allwinner A1X Pin Controller Device Tree Example Source: https://github.com/william24hmar/android_kernel_nothing_sm7325/blob/lineage-23.0/arch/arm64/boot/dts/vendor/bindings/pinctrl/allwinner,sunxi-pinctrl.txt Example device tree configuration for the Allwinner A1X Pin Controller, showing pin multiplexing and configuration for UART1. ```Device Tree pio: pinctrl@1c20800 { compatible = "allwinner,sun5i-a13-pinctrl"; reg = <0x01c20800 0x400>; #address-cells = <1>; #size-cells = <0>; uart1_pins_a: uart1@0 { allwinner,pins = "PE10", "PE11"; allwinner,function = "uart1"; allwinner,drive = <0>; allwinner,pull = <0>; }; uart1_pins_b: uart1@1 { allwinner,pins = "PG3", "PG4"; allwinner,function = "uart1"; allwinner,drive = <0>; allwinner,pull = <0>; }; }; ``` -------------------------------- ### TCA6507 LED Sub-node Configuration Examples Source: https://github.com/william24hmar/android_kernel_nothing_sm7325/blob/lineage-23.0/arch/arm64/boot/dts/vendor/bindings/leds/tca6507.txt Illustrates the configuration of individual LED sub-nodes within the TCA6507 device tree node. Examples show basic LED setup, an LED with a default trigger, and a GPIO-compatible node. ```devicetree led0: red-aux@0 { label = "red:aux"; reg = <0x0>; }; ``` ```devicetree led1: green-aux@1 { label = "green:aux"; reg = <0x5>; linux,default-trigger = "default-on"; }; ``` ```devicetree wifi-reset@6 { reg = <0x6>; compatible = "gpio"; }; ``` -------------------------------- ### Kref Release Function Example Source: https://github.com/william24hmar/android_kernel_nothing_sm7325/blob/lineage-23.0/Documentation/kref.txt Provides an example of a kref release function. This function is responsible for freeing the memory associated with the data structure once its reference count reaches zero. It uses container_of to get the surrounding structure from the kref. ```c void data_release(struct kref *ref) { struct my_data *data = container_of(ref, struct my_data, refcount); kfree(data); } ``` -------------------------------- ### Armada 370 DB Audio Device Tree Example Source: https://github.com/william24hmar/android_kernel_nothing_sm7325/blob/lineage-23.0/arch/arm64/boot/dts/vendor/bindings/sound/armada-370db-audio.txt An example configuration snippet demonstrating the Armada 370 DB audio device tree bindings. It shows how to define the 'sound' node with required properties to connect audio components. This is a key part of configuring the audio subsystem. ```Device Tree sound { compatible = "marvell,a370db-audio"; marvell,audio-controller = <&audio_controller>; marvell,audio-codec = <&audio_codec &spdif_out &spdif_in>; }; ``` -------------------------------- ### GPIO LED Configuration Example Source: https://github.com/william24hmar/android_kernel_nothing_sm7325/blob/lineage-23.0/arch/arm64/boot/dts/vendor/bindings/leds/leds-gpio.txt This example demonstrates the configuration of two LEDs (led0 and led1) connected to GPIO pins. It specifies the GPIO controller, pin number, active state, default trigger for disk activity, and the LED function. ```Device Tree #include #include leds { compatible = "gpio-leds"; led0 { gpios = <&mcu_pio 0 GPIO_ACTIVE_LOW>; linux,default-trigger = "disk-activity"; function = LED_FUNCTION_DISK; }; led1 { gpios = <&mcu_pio 1 GPIO_ACTIVE_HIGH>; /* Keep LED on if BIOS detected hardware fault */ default-state = "keep"; function = LED_FUNCTION_FAULT; }; }; ``` -------------------------------- ### Install VMA Policy for Address Range Source: https://github.com/william24hmar/android_kernel_nothing_sm7325/blob/lineage-23.0/Documentation/admin-guide/mm/numa_memory_policy.rst Installs a policy for a specified range of the task's address space. Depends on system call interface. Takes start address, length, mode, nmask, maxnode, and flags as parameters. ```c long mbind(void *start, unsigned long len, int mode, const unsigned long *nmask, unsigned long maxnode, unsigned flags); ``` -------------------------------- ### Device Tree Configuration for Qualcomm RPM SMD Source: https://github.com/william24hmar/android_kernel_nothing_sm7325/blob/lineage-23.0/arch/arm64/boot/dts/vendor/bindings/soc/qcom/qcom,smd-rpm.txt Device tree binding example showing how to configure the Qualcomm RPM SMD driver with required properties, interrupts, IPC settings, and SMD edge configuration. The example demonstrates setting up RPM requests with compatible values and SMD channels. ```Device Tree soc { apcs: syscon@f9011000 { compatible = "syscon"; reg = <0xf9011000 0x1000>; }; }; smd { compatible = "qcom,smd"; rpm { interrupts = <0 168 1>; qcom,ipc = <&apcs 8 0>; qcom,smd-edge = <15>; rpm_requests { compatible = "qcom,rpm-msm8974"; qcom,smd-channels = "rpm_requests"; ... }; }; }; ``` -------------------------------- ### GPIO LED Controller Example in DTS Source: https://github.com/william24hmar/android_kernel_nothing_sm7325/blob/lineage-23.0/arch/arm64/boot/dts/vendor/bindings/leds/common.txt This example configures a GPIO-based LED controller with status and USB function LEDs, including default triggers and GPIO mappings. It depends on gpio0 for pin assignments. No specific limitations are noted for this setup. ```dts #include led-controller@0 { compatible = "gpio-leds"; led0 { function = LED_FUNCTION_STATUS; linux,default-trigger = "heartbeat"; gpios = <&gpio0 0 GPIO_ACTIVE_HIGH>; }; led1 { function = LED_FUNCTION_USB; gpios = <&gpio0 1 GPIO_ACTIVE_HIGH>; trigger-sources = <&ohci_port1>, <&ehci_port1>; }; }; ``` -------------------------------- ### Allwinner Clock Controller Device Tree Examples Source: https://github.com/william24hmar/android_kernel_nothing_sm7325/blob/lineage-23.0/arch/arm64/boot/dts/vendor/bindings/clock/sunxi.txt These Device Tree source examples demonstrate clock controller configurations for Allwinner SoCs, covering oscillator, PLL, CPU, MMC, GMAC, and fixed clock types. Each example illustrates required properties including compatible strings, register addresses, parent clock references, and output naming conventions per the binding specification. The examples show proper cell counts and clock dependency declarations for different hardware blocks. ```dts osc24M: clk@1c20050 { #clock-cells = <0>; compatible = "allwinner,sun4i-a10-osc-clk"; reg = <0x01c20050 0x4>; clocks = <&osc24M_fixed>; clock-output-names = "osc24M"; }; ``` ```dts pll1: clk@1c20000 { #clock-cells = <0>; compatible = "allwinner,sun4i-a10-pll1-clk"; reg = <0x01c20000 0x4>; clocks = <&osc24M>; clock-output-names = "pll1"; }; ``` ```dts pll5: clk@1c20020 { #clock-cells = <1>; compatible = "allwinner,sun4i-pll5-clk"; reg = <0x01c20020 0x4>; clocks = <&osc24M>; clock-output-names = "pll5_ddr", "pll5_other"; }; ``` ```dts pll6: clk@1c20028 { #clock-cells = <1>; compatible = "allwinner,sun6i-a31-pll6-clk"; reg = <0x01c20028 0x4>; clocks = <&osc24M>; clock-output-names = "pll6", "pll6x2"; }; ``` ```dts cpu: cpu@1c20054 { #clock-cells = <0>; compatible = "allwinner,sun4i-a10-cpu-clk"; reg = <0x01c20054 0x4>; clocks = <&osc32k>, <&osc24M>, <&pll1>; clock-output-names = "cpu"; }; ``` ```dts mmc0_clk: clk@1c20088 { #clock-cells = <1>; compatible = "allwinner,sun4i-a10-mmc-clk"; reg = <0x01c20088 0x4>; clocks = <&osc24M>, <&pll6 1>, <&pll5 1>; clock-output-names = "mmc0", "mmc0_output", "mmc0_sample"; }; ``` ```dts mii_phy_tx_clk: clk@2 { #clock-cells = <0>; compatible = "fixed-clock"; clock-frequency = <25000000>; clock-output-names = "mii_phy_tx"; }; ``` ```dts gmac_int_tx_clk: clk@3 { #clock-cells = <0>; compatible = "fixed-clock"; clock-frequency = <125000000>; clock-output-names = "gmac_int_tx"; }; ``` ```dts gmac_clk: clk@1c20164 { #clock-cells = <0>; compatible = "allwinner,sun7i-a20-gmac-clk"; reg = <0x01c20164 0x4>; /* * The first clock must be fixed at 25MHz; * the second clock must be fixed at 125MHz */ clocks = <&mii_phy_tx_clk>, <&gmac_int_tx_clk>; clock-output-names = "gmac"; }; ``` ```dts mmc_config_clk: clk@1c13000 { compatible = "allwinner,sun9i-a80-mmc-config-clk"; reg = <0x01c13000 0x10>; clocks = <&ahb0_gates 8>; clock-names = "ahb"; resets = <&ahb0_resets 8>; reset-names = "ahb"; #clock-cells = <1>; #reset-cells = <1>; clock-output-names = "mmc0_config", "mmc1_config", "mmc2_config", "mmc3_config"; }; ``` -------------------------------- ### Rockchip I2S Controller Configuration Example Source: https://github.com/william24hmar/android_kernel_nothing_sm7325/blob/lineage-23.0/arch/arm64/boot/dts/vendor/bindings/sound/rockchip-i2s.txt Example configuration for the rk3288 I2S controller, including compatible strings, registers, interrupts, DMA settings, and clock configurations. This setup is essential for enabling digital audio data transfer on Rockchip platforms. ```Device Tree i2s@ff890000 { compatible = "rockchip,rk3288-i2s", "rockchip,rk3066-i2s"; reg = <0xff890000 0x10000>; interrupts = ; dmas = <&pdma1 0>, <&pdma1 1>; dma-names = "tx", "rx"; clock-names = "i2s_hclk", "i2s_clk"; clocks = <&cru HCLK_I2S0>, <&cru SCLK_I2S0>; rockchip,playback-channels = <8>; rockchip,capture-channels = <2>; }; ``` -------------------------------- ### IIO Triggered Buffer Setup Operations and Handler - C Source: https://github.com/william24hmar/android_kernel_nothing_sm7325/blob/lineage-23.0/Documentation/driver-api/iio/triggered-buffers.rst Defines the `iio_buffer_setup_ops` structure for callbacks during triggered buffer configuration and provides example functions for the poll function's top and bottom halves, along with the core `iio_triggered_buffer_setup` call. ```c const struct iio_buffer_setup_ops sensor_buffer_setup_ops = { .preenable = sensor_buffer_preenable, .postenable = sensor_buffer_postenable, .postdisable = sensor_buffer_postdisable, .predisable = sensor_buffer_predisable, }; irqreturn_t sensor_iio_pollfunc(int irq, void *p) { pf->timestamp = iio_get_time_ns((struct indio_dev *)p); return IRQ_WAKE_THREAD; } irqreturn_t sensor_trigger_handler(int irq, void *p) { u16 buf[8]; int i = 0; /* read data for each active channel */ for_each_set_bit(bit, active_scan_mask, masklength) buf[i++] = sensor_get_data(bit) iio_push_to_buffers_with_timestamp(indio_dev, buf, timestamp); iio_trigger_notify_done(trigger); return IRQ_HANDLED; } /* setup triggered buffer, usually in probe function */ iio_triggered_buffer_setup(indio_dev, sensor_iio_polfunc, sensor_trigger_handler, sensor_buffer_setup_ops); ``` -------------------------------- ### Allwinner SRAM Controller Device Tree Example Source: https://github.com/william24hmar/android_kernel_nothing_sm7325/blob/lineage-23.0/arch/arm64/boot/dts/vendor/bindings/sram/sunxi-sram.txt Example device tree configuration for an Allwinner SRAM controller, showing the controller node and an SRAM section with a specific compatible string and register mappings. ```Device Tree system-control@1c00000 { compatible = "allwinner,sun4i-a10-system-control"; reg = <0x01c00000 0x30>; #address-cells = <1>; #size-cells = <1>; ranges; sram_a: sram@00000000 { compatible = "mmio-sram"; reg = <0x00000000 0xc000>; #address-cells = <1>; #size-cells = <1>; ranges = <0 0x00000000 0xc000>; emac_sram: sram-section@8000 { compatible = "allwinner,sun4i-a10-sram-a3-a4"; reg = <0x8000 0x4000>; }; }; }; ``` ```Device Tree emac: ethernet@1c0b000 { compatible = "allwinner,sun4i-a10-emac"; ... allwinner,sram = <&emac_sram 1>; }; ``` -------------------------------- ### SBS Charger Device Tree Node Example Source: https://github.com/william24hmar/android_kernel_nothing_sm7325/blob/lineage-23.0/arch/arm64/boot/dts/vendor/bindings/power/supply/sbs_sbs-charger.txt This example configures an LTC4100 charger device using SBS binding. It specifies the compatible strings, I2C address via reg, and interrupt setup. Requires GPIO controller reference; supports polling if interrupts are omitted. ```dts ltc4100@9 { compatible = "lltc,ltc4100", "sbs,sbs-charger"; reg = <0x9>; interrupt-parent = <&gpio6>; interrupts = <7 IRQ_TYPE_LEVEL_LOW>; }; ```