--- zzzz-none-000/linux-5.4.213/kernel/resource.c 2022-09-15 10:04:56.000000000 +0000 +++ miami-7690-761/linux-5.4.213/kernel/resource.c 2024-05-29 11:20:02.000000000 +0000 @@ -43,6 +43,39 @@ }; EXPORT_SYMBOL(iomem_resource); +#ifdef CONFIG_AVM_ENHANCED +struct resource sflash_resource = { + .name = "SFLASH", + .start = 0, + .end = 1024*1024, + .flags = IORESOURCE_MEM, +}; +EXPORT_SYMBOL(sflash_resource); + +struct resource nand_flash_resource = { + .name = "NAND", + .start = 0, + .end = 1024*1024, /*--- Angaben in MByte ---*/ + .flags = IORESOURCE_MEM, +}; +EXPORT_SYMBOL(nand_flash_resource); + +struct resource gpio_resource = { + .name = "gpio", + .start = 0, +# if defined (CONFIG_SOC_QCA955X) || defined(CONFIG_SOC_AR934X) || defined (CONFIG_SOC_QCA953X) + .end = 116, /*--- 0..22, Shiftregister: 101..116 ---*/ +# elif defined (CONFIG_ARCH_IPQ806X_DT) + .end = 69, +# else /*--- #if defined (CONFIG_SOC_QCA955X) || defined(CONFIG_SOC_AR934X) ---*/ + .end = 64, +# endif /*--- #else ---*/ /*--- #if defined (CONFIG_SOC_QCA955X) || defined(CONFIG_SOC_AR934X) ---*/ + .flags = IORESOURCE_IO +}; +EXPORT_SYMBOL(gpio_resource); + +#endif /* CONFIG_AVM_ENHANCED */ + /* constraints to be met while allocating resources */ struct resource_constraint { resource_size_t min, max, align; @@ -147,6 +180,34 @@ #endif /* CONFIG_PROC_FS */ +#ifdef CONFIG_AVM_ENHANCED +void print_resource_tree(struct resource *root __attribute__ ((unused)), unsigned int level __attribute__ ((unused))) +{ +#if defined(DEBUG_RESOURCE) + static const char *indent[] = { + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " + }; + + if (level == 0) + printk(KERN_ERR "[resource-tree] "); + while (root) { + printk(KERN_ERR "%d:%s[%s] (0x%pa - 0x%pa)\n", level, indent[level], root->name, &root->start, &root->end); + if (root->child) { + print_resource_tree(root->child, level + 1); + } + root = root->sibling; + } +#endif /*--- #if defined(DEBUG_RESOURCE) ---*/ +} +#endif + static void free_resource(struct resource *res) { if (!res) @@ -187,13 +248,30 @@ resource_size_t start = new->start; resource_size_t end = new->end; struct resource *tmp, **p; - - if (end < start) +#if defined(CONFIG_AVM_ENHANCED) && defined(DEBUG_RESOURCE) + const int debug_resource = 1; +#else + const int debug_resource = 0; +#endif + + if (end < start) { + if (debug_resource) + pr_err("[request_resource] %s: end 0x%pa < start " + "0x%pa\n", new->name, &end, &start); return root; - if (start < root->start) + } + if (start < root->start) { + if (debug_resource) + pr_err("[request_resource] %s: start 0x%pa < root->start " + "0x%pa\n", new->name, &start, &root->start); return root; - if (end > root->end) + } + if (end > root->end) { + if (debug_resource) + pr_err("[request_resource] %s: end 0x%pa > root->end " + "0x%pa\n", new->name, &end, &root->end); return root; + } p = &root->child; for (;;) { tmp = *p; @@ -450,6 +528,7 @@ return __walk_iomem_res_desc(start, end, flags, IORES_DESC_NONE, true, arg, func); } +EXPORT_SYMBOL_GPL(walk_system_ram_res); /* * This function calls the @func callback against all memory ranges, which @@ -597,6 +676,7 @@ struct resource *this = root->child; struct resource tmp = *new, avail, alloc; + tmp.flags = new->flags; tmp.start = root->start; /* * Skip past an allocated resource that starts at 0, since the assignment