Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2)  * Flash and EPROM on Hitachi Solution Engine and similar boards.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  * (C) 2001 Red Hat, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  * GPL'd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <asm/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/mtd/mtd.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/mtd/map.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/mtd/partitions.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) static struct mtd_info *flash_mtd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) static struct mtd_info *eprom_mtd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) struct map_info soleng_eprom_map = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 	.name = "Solution Engine EPROM",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 	.size = 0x400000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 	.bankwidth = 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) struct map_info soleng_flash_map = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 	.name = "Solution Engine FLASH",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 	.size = 0x400000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	.bankwidth = 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) static const char * const probes[] = { "RedBoot", "cmdlinepart", NULL };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) static int __init init_soleng_maps(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 	/* First probe at offset 0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 	soleng_flash_map.phys = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 	soleng_flash_map.virt = (void __iomem *)P2SEGADDR(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 	soleng_eprom_map.phys = 0x01000000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 	soleng_eprom_map.virt = (void __iomem *)P1SEGADDR(0x01000000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 	simple_map_init(&soleng_eprom_map);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 	simple_map_init(&soleng_flash_map);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 	printk(KERN_NOTICE "Probing for flash chips at 0x00000000:\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 	flash_mtd = do_map_probe("cfi_probe", &soleng_flash_map);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 	if (!flash_mtd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 		/* Not there. Try swapping */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 		printk(KERN_NOTICE "Probing for flash chips at 0x01000000:\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 		soleng_flash_map.phys = 0x01000000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 		soleng_flash_map.virt = P2SEGADDR(0x01000000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 		soleng_eprom_map.phys = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 		soleng_eprom_map.virt = P1SEGADDR(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 		flash_mtd = do_map_probe("cfi_probe", &soleng_flash_map);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 		if (!flash_mtd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 			/* Eep. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 			printk(KERN_NOTICE "Flash chips not detected at either possible location.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 			return -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 	printk(KERN_NOTICE "Solution Engine: Flash at 0x%pap, EPROM at 0x%pap\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 	       &soleng_flash_map.phys,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 	       &soleng_eprom_map.phys);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) 	flash_mtd->owner = THIS_MODULE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) 	eprom_mtd = do_map_probe("map_rom", &soleng_eprom_map);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) 	if (eprom_mtd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) 		eprom_mtd->owner = THIS_MODULE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) 		mtd_device_register(eprom_mtd, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) 	mtd_device_parse_register(flash_mtd, probes, NULL, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) static void __exit cleanup_soleng_maps(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) 	if (eprom_mtd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) 		mtd_device_unregister(eprom_mtd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) 		map_destroy(eprom_mtd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) 	mtd_device_unregister(flash_mtd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) 	map_destroy(flash_mtd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) module_init(init_soleng_maps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) module_exit(cleanup_soleng_maps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) MODULE_DESCRIPTION("MTD map driver for Hitachi SolutionEngine (and similar) boards");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)