Module Name: src Committed By: skrll Date: Wed Feb 23 08:56:11 UTC 2022
Modified Files: src/sys/dev/fdt: fdtvar.h Log Message: Sort a bit. NFC To generate a diff of this commit: cvs rdiff -u -r1.75 -r1.76 src/sys/dev/fdt/fdtvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/fdt/fdtvar.h diff -u src/sys/dev/fdt/fdtvar.h:1.75 src/sys/dev/fdt/fdtvar.h:1.76 --- src/sys/dev/fdt/fdtvar.h:1.75 Wed Feb 23 07:55:55 2022 +++ src/sys/dev/fdt/fdtvar.h Wed Feb 23 08:56:11 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: fdtvar.h,v 1.75 2022/02/23 07:55:55 skrll Exp $ */ +/* $NetBSD: fdtvar.h,v 1.76 2022/02/23 08:56:11 skrll Exp $ */ /*- * Copyright (c) 2015 Jared D. McNeill <jmcne...@invisible.ca> @@ -59,95 +59,17 @@ struct fdt_attach_args { int faa_quiet; }; -/* flags for fdtbus_intr_establish */ -#define FDT_INTR_MPSAFE __BIT(0) - -/* Interrupt trigger types defined by the FDT "interrupts" bindings. */ -#define FDT_INTR_TYPE_POS_EDGE __BIT(0) -#define FDT_INTR_TYPE_NEG_EDGE __BIT(1) -#define FDT_INTR_TYPE_DOUBLE_EDGE (FDT_INTR_TYPE_POS_EDGE | \ - FDT_INTR_TYPE_NEG_EDGE) -#define FDT_INTR_TYPE_HIGH_LEVEL __BIT(2) -#define FDT_INTR_TYPE_LOW_LEVEL __BIT(3) - -struct fdtbus_interrupt_controller_func { - void * (*establish)(device_t, u_int *, int, int, - int (*)(void *), void *, const char *); - void (*disestablish)(device_t, void *); - bool (*intrstr)(device_t, u_int *, char *, size_t); - void (*mask)(device_t, void *); - void (*unmask)(device_t, void *); -}; - -struct fdtbus_spi_controller_func { - struct spi_controller * (*get_controller)(device_t); -}; - -struct fdtbus_gpio_controller; - -struct fdtbus_gpio_pin { - struct fdtbus_gpio_controller *gp_gc; - void *gp_priv; -}; - -struct fdtbus_gpio_controller_func { - void * (*acquire)(device_t, const void *, size_t, int); - void (*release)(device_t, void *); - int (*read)(device_t, void *, bool); - void (*write)(device_t, void *, int, bool); -}; - -struct fdtbus_pinctrl_controller; - -struct fdtbus_pinctrl_pin { - struct fdtbus_pinctrl_controller *pp_pc; - void *pp_priv; -}; - -struct fdtbus_pinctrl_controller_func { - int (*set_config)(device_t, const void *, size_t); -}; - -struct fdtbus_iommu_func { - bus_dma_tag_t (*map)(device_t, const u_int *, bus_dma_tag_t); -}; - -struct fdtbus_regulator_controller; - -struct fdtbus_regulator { - struct fdtbus_regulator_controller *reg_rc; -}; - -struct fdtbus_regulator_controller_func { - int (*acquire)(device_t); - void (*release)(device_t); - int (*enable)(device_t, bool); - int (*set_voltage)(device_t, u_int, u_int); - int (*get_voltage)(device_t, u_int *); -}; struct fdtbus_clock_controller_func { struct clk * (*decode)(device_t, int, const void *, size_t); }; -struct fdtbus_reset_controller; - -struct fdtbus_reset { - struct fdtbus_reset_controller *rst_rc; - void *rst_priv; -}; - -struct fdtbus_reset_controller_func { - void * (*acquire)(device_t, const void *, size_t); - void (*release)(device_t, void *); - int (*reset_assert)(device_t, void *); - int (*reset_deassert)(device_t, void *); -}; struct fdtbus_dai_controller_func { audio_dai_tag_t (*get_tag)(device_t, const void *, size_t); }; + struct fdtbus_dma_controller; struct fdtbus_dma { @@ -193,13 +115,58 @@ struct fdtbus_dma_controller_func { void (*halt)(device_t, void *); }; -struct fdtbus_power_controller; -struct fdtbus_power_controller_func { - void (*reset)(device_t); - void (*poweroff)(device_t); +struct fdtbus_gpio_controller; + +struct fdtbus_gpio_pin { + struct fdtbus_gpio_controller *gp_gc; + void *gp_priv; +}; + +struct fdtbus_gpio_controller_func { + void * (*acquire)(device_t, const void *, size_t, int); + void (*release)(device_t, void *); + int (*read)(device_t, void *, bool); + void (*write)(device_t, void *, int, bool); +}; + + +/* flags for fdtbus_intr_establish */ +#define FDT_INTR_MPSAFE __BIT(0) + +/* Interrupt trigger types defined by the FDT "interrupts" bindings. */ +#define FDT_INTR_TYPE_POS_EDGE __BIT(0) +#define FDT_INTR_TYPE_NEG_EDGE __BIT(1) +#define FDT_INTR_TYPE_DOUBLE_EDGE (FDT_INTR_TYPE_POS_EDGE | \ + FDT_INTR_TYPE_NEG_EDGE) +#define FDT_INTR_TYPE_HIGH_LEVEL __BIT(2) +#define FDT_INTR_TYPE_LOW_LEVEL __BIT(3) + +struct fdtbus_interrupt_controller_func { + void * (*establish)(device_t, u_int *, int, int, + int (*)(void *), void *, const char *); + void (*disestablish)(device_t, void *); + bool (*intrstr)(device_t, u_int *, char *, size_t); + void (*mask)(device_t, void *); + void (*unmask)(device_t, void *); +}; + + +struct fdtbus_iommu_func { + bus_dma_tag_t (*map)(device_t, const u_int *, bus_dma_tag_t); +}; + + +struct fdtbus_mmc_pwrseq; + +struct fdtbus_mmc_pwrseq_func { + void (*pre_power_on)(device_t); + void (*post_power_on)(device_t); + void (*power_off)(device_t); + void (*reset)(device_t); }; + struct fdtbus_phy_controller; struct fdtbus_phy { @@ -213,21 +180,70 @@ struct fdtbus_phy_controller_func { int (*enable)(device_t, void *, bool); }; + +struct fdtbus_pinctrl_controller; + +struct fdtbus_pinctrl_pin { + struct fdtbus_pinctrl_controller *pp_pc; + void *pp_priv; +}; + +struct fdtbus_pinctrl_controller_func { + int (*set_config)(device_t, const void *, size_t); +}; + + +struct fdtbus_power_controller; + +struct fdtbus_power_controller_func { + void (*reset)(device_t); + void (*poweroff)(device_t); +}; + + struct fdtbus_pwm_controller_func { pwm_tag_t (*get_tag)(device_t, const void *, size_t); }; -struct fdtbus_mmc_pwrseq; -struct fdtbus_mmc_pwrseq_func { - void (*pre_power_on)(device_t); - void (*post_power_on)(device_t); - void (*power_off)(device_t); - void (*reset)(device_t); +struct fdtbus_regulator_controller; + +struct fdtbus_regulator { + struct fdtbus_regulator_controller *reg_rc; }; +struct fdtbus_regulator_controller_func { + int (*acquire)(device_t); + void (*release)(device_t); + int (*enable)(device_t, bool); + int (*set_voltage)(device_t, u_int, u_int); + int (*get_voltage)(device_t, u_int *); +}; + + +struct fdtbus_reset_controller; + +struct fdtbus_reset { + struct fdtbus_reset_controller *rst_rc; + void *rst_priv; +}; + +struct fdtbus_reset_controller_func { + void * (*acquire)(device_t, const void *, size_t); + void (*release)(device_t, void *); + int (*reset_assert)(device_t, void *); + int (*reset_deassert)(device_t, void *); +}; + + +struct fdtbus_spi_controller_func { + struct spi_controller * (*get_controller)(device_t); +}; + + struct syscon; + struct fdt_console { int (*match)(int); void (*consinit)(struct fdt_attach_args *, u_int); @@ -277,36 +293,36 @@ struct fdt_dma_range { #define FDT_BUS_SPACE_FLAG_NONPOSTED_MMIO __BIT(0) -int fdtbus_register_interrupt_controller(device_t, int, - const struct fdtbus_interrupt_controller_func *); -int fdtbus_register_i2c_controller(i2c_tag_t, int); -int fdtbus_register_spi_controller(device_t, int, - const struct fdtbus_spi_controller_func *); -int fdtbus_register_gpio_controller(device_t, int, - const struct fdtbus_gpio_controller_func *); -int fdtbus_register_pinctrl_config(device_t, int, - const struct fdtbus_pinctrl_controller_func *); -int fdtbus_register_regulator_controller(device_t, int, - const struct fdtbus_regulator_controller_func *); int fdtbus_register_clock_controller(device_t, int, const struct fdtbus_clock_controller_func *); -int fdtbus_register_reset_controller(device_t, int, - const struct fdtbus_reset_controller_func *); int fdtbus_register_dai_controller(device_t, int, const struct fdtbus_dai_controller_func *); int fdtbus_register_dma_controller(device_t, int, const struct fdtbus_dma_controller_func *); +int fdtbus_register_gpio_controller(device_t, int, + const struct fdtbus_gpio_controller_func *); +int fdtbus_register_i2c_controller(i2c_tag_t, int); +int fdtbus_register_interrupt_controller(device_t, int, + const struct fdtbus_interrupt_controller_func *); +int fdtbus_register_iommu(device_t, int, + const struct fdtbus_iommu_func *); +int fdtbus_register_mmc_pwrseq(device_t, int, + const struct fdtbus_mmc_pwrseq_func *); +int fdtbus_register_pinctrl_config(device_t, int, + const struct fdtbus_pinctrl_controller_func *); int fdtbus_register_power_controller(device_t, int, const struct fdtbus_power_controller_func *); int fdtbus_register_phy_controller(device_t, int, const struct fdtbus_phy_controller_func *); int fdtbus_register_pwm_controller(device_t, int, const struct fdtbus_pwm_controller_func *); -int fdtbus_register_mmc_pwrseq(device_t, int, - const struct fdtbus_mmc_pwrseq_func *); +int fdtbus_register_regulator_controller(device_t, int, + const struct fdtbus_regulator_controller_func *); +int fdtbus_register_reset_controller(device_t, int, + const struct fdtbus_reset_controller_func *); +int fdtbus_register_spi_controller(device_t, int, + const struct fdtbus_spi_controller_func *); int fdtbus_register_syscon(device_t, int, struct syscon *); -int fdtbus_register_iommu(device_t, int, - const struct fdtbus_iommu_func *); void fdtbus_set_decoderegprop(bool); @@ -322,6 +338,39 @@ int fdtbus_get_phandle_with_data(int, c int, struct fdt_phandle_data *); int fdtbus_get_phandle_from_native(int); + +struct clk * fdtbus_clock_get(int, const char *); +struct clk * fdtbus_clock_get_index(int, u_int); +struct clk * fdtbus_clock_byname(const char *); +void fdtbus_clock_assign(int); +u_int fdtbus_clock_count(int, const char *); +int fdtbus_clock_enable(int, const char *, bool); +int fdtbus_clock_enable_index(int, u_int, bool); + +audio_dai_tag_t fdtbus_dai_acquire(int, const char *); +audio_dai_tag_t fdtbus_dai_acquire_index(int, const char *, int); + +struct fdtbus_dma * + fdtbus_dma_get(int, const char *, void (*)(void *), void *); +struct fdtbus_dma * + fdtbus_dma_get_index(int, u_int, void (*)(void *), + void *); +void fdtbus_dma_put(struct fdtbus_dma *); +int fdtbus_dma_transfer(struct fdtbus_dma *, + struct fdtbus_dma_req *); +void fdtbus_dma_halt(struct fdtbus_dma *); + +int fdtbus_gpio_count(int, const char *); +struct fdtbus_gpio_pin * + fdtbus_gpio_acquire(int, const char *, int); +struct fdtbus_gpio_pin * + fdtbus_gpio_acquire_index(int, const char *, int, int); +void fdtbus_gpio_release(struct fdtbus_gpio_pin *); +int fdtbus_gpio_read(struct fdtbus_gpio_pin *); +void fdtbus_gpio_write(struct fdtbus_gpio_pin *, int); +int fdtbus_gpio_read_raw(struct fdtbus_gpio_pin *); +void fdtbus_gpio_write_raw(struct fdtbus_gpio_pin *, int); + i2c_tag_t fdtbus_i2c_get_tag(int); i2c_tag_t fdtbus_i2c_acquire(int, const char *); @@ -340,22 +389,23 @@ bool fdtbus_intr_str(int, u_int, char * bool fdtbus_intr_str_raw(int, const u_int *, char *, size_t); int fdtbus_intr_parent(int); -int fdtbus_gpio_count(int, const char *); -struct fdtbus_gpio_pin * - fdtbus_gpio_acquire(int, const char *, int); -struct fdtbus_gpio_pin * - fdtbus_gpio_acquire_index(int, const char *, int, int); -void fdtbus_gpio_release(struct fdtbus_gpio_pin *); -int fdtbus_gpio_read(struct fdtbus_gpio_pin *); -void fdtbus_gpio_write(struct fdtbus_gpio_pin *, int); -int fdtbus_gpio_read_raw(struct fdtbus_gpio_pin *); -void fdtbus_gpio_write_raw(struct fdtbus_gpio_pin *, int); +bus_dma_tag_t fdtbus_iommu_map(int, u_int, bus_dma_tag_t); +bus_dma_tag_t fdtbus_iommu_map_pci(int, uint32_t, bus_dma_tag_t); -audio_dai_tag_t fdtbus_dai_acquire(int, const char *); -audio_dai_tag_t fdtbus_dai_acquire_index(int, const char *, int); +struct fdtbus_mmc_pwrseq * + fdtbus_mmc_pwrseq_get(int); +void fdtbus_mmc_pwrseq_pre_power_on(struct fdtbus_mmc_pwrseq *); +void fdtbus_mmc_pwrseq_post_power_on(struct fdtbus_mmc_pwrseq *); +void fdtbus_mmc_pwrseq_power_off(struct fdtbus_mmc_pwrseq *); +void fdtbus_mmc_pwrseq_reset(struct fdtbus_mmc_pwrseq *); -pwm_tag_t fdtbus_pwm_acquire(int, const char *); -pwm_tag_t fdtbus_pwm_acquire_index(int, const char *, int); +struct fdtbus_phy * + fdtbus_phy_get(int, const char *); +struct fdtbus_phy * + fdtbus_phy_get_index(int, u_int); +void fdtbus_phy_put(struct fdtbus_phy *); +device_t fdtbus_phy_device(struct fdtbus_phy *); +int fdtbus_phy_enable(struct fdtbus_phy *, bool); int fdtbus_pinctrl_set_config_index(int, u_int); int fdtbus_pinctrl_set_config(int, const char *); @@ -369,6 +419,9 @@ int fdtbus_pinctrl_parse_drive(int); int fdtbus_pinctrl_parse_drive_strength(int); int fdtbus_pinctrl_parse_input_output(int, int *); +pwm_tag_t fdtbus_pwm_acquire(int, const char *); +pwm_tag_t fdtbus_pwm_acquire_index(int, const char *, int); + struct fdtbus_regulator * fdtbus_regulator_acquire(int, const char *); void fdtbus_regulator_release(struct fdtbus_regulator *); @@ -381,30 +434,6 @@ int fdtbus_regulator_get_voltage(struct int fdtbus_regulator_supports_voltage(struct fdtbus_regulator *, u_int, u_int); -struct syscon * fdtbus_syscon_acquire(int, const char *); -struct syscon * fdtbus_syscon_lookup(int); - -bus_dma_tag_t fdtbus_iommu_map(int, u_int, bus_dma_tag_t); -bus_dma_tag_t fdtbus_iommu_map_pci(int, uint32_t, bus_dma_tag_t); - -struct fdtbus_dma * - fdtbus_dma_get(int, const char *, void (*)(void *), void *); -struct fdtbus_dma * - fdtbus_dma_get_index(int, u_int, void (*)(void *), - void *); -void fdtbus_dma_put(struct fdtbus_dma *); -int fdtbus_dma_transfer(struct fdtbus_dma *, - struct fdtbus_dma_req *); -void fdtbus_dma_halt(struct fdtbus_dma *); - -struct clk * fdtbus_clock_get(int, const char *); -struct clk * fdtbus_clock_get_index(int, u_int); -struct clk * fdtbus_clock_byname(const char *); -void fdtbus_clock_assign(int); -u_int fdtbus_clock_count(int, const char *); -int fdtbus_clock_enable(int, const char *, bool); -int fdtbus_clock_enable_index(int, u_int, bool); - struct fdtbus_reset * fdtbus_reset_get(int, const char *); struct fdtbus_reset * @@ -413,26 +442,15 @@ void fdtbus_reset_put(struct fdtbus_res int fdtbus_reset_assert(struct fdtbus_reset *); int fdtbus_reset_deassert(struct fdtbus_reset *); -struct fdtbus_phy * - fdtbus_phy_get(int, const char *); -struct fdtbus_phy * - fdtbus_phy_get_index(int, u_int); -void fdtbus_phy_put(struct fdtbus_phy *); -device_t fdtbus_phy_device(struct fdtbus_phy *); -int fdtbus_phy_enable(struct fdtbus_phy *, bool); - -struct fdtbus_mmc_pwrseq * - fdtbus_mmc_pwrseq_get(int); -void fdtbus_mmc_pwrseq_pre_power_on(struct fdtbus_mmc_pwrseq *); -void fdtbus_mmc_pwrseq_post_power_on(struct fdtbus_mmc_pwrseq *); -void fdtbus_mmc_pwrseq_power_off(struct fdtbus_mmc_pwrseq *); -void fdtbus_mmc_pwrseq_reset(struct fdtbus_mmc_pwrseq *); - int fdtbus_todr_attach(device_t, int, todr_chip_handle_t); void fdtbus_power_reset(void); void fdtbus_power_poweroff(void); +struct syscon * fdtbus_syscon_acquire(int, const char *); +struct syscon * fdtbus_syscon_lookup(int); + + device_t fdtbus_attach_i2cbus(device_t, int, i2c_tag_t, cfprint_t); device_t fdtbus_attach_spibus(device_t, int, cfprint_t); @@ -472,4 +490,5 @@ bus_dma_tag_t fdtbus_dma_tag_create(int, u_int); bus_space_tag_t fdtbus_bus_tag_create(int, uint32_t); + #endif /* _DEV_FDT_FDTVAR_H_ */