Lines Matching +full:charge +full:- +full:ctrl +full:- +full:value

7  * Permission is hereby granted, free of charge, to any person obtaining a copy
28 #include "libqtest-single.h"
30 #include "aspeed-smc-utils.h"
42 uint32_t value) in spi_writel() argument
44 qtest_writel(data->s, data->spi_base + offset, value); in spi_writel()
49 return qtest_readl(data->s, data->spi_base + offset); in spi_readl()
53 uint8_t value) in flash_writeb() argument
55 qtest_writeb(data->s, data->flash_base + offset, value); in flash_writeb()
59 uint32_t value) in flash_writel() argument
61 qtest_writel(data->s, data->flash_base + offset, value); in flash_writel()
67 return qtest_readb(data->s, data->flash_base + offset); in flash_readb()
73 return qtest_readl(data->s, data->flash_base + offset); in flash_readl()
76 static void spi_conf(const AspeedSMCTestData *data, uint32_t value) in spi_conf() argument
80 conf |= value; in spi_conf()
84 static void spi_conf_remove(const AspeedSMCTestData *data, uint32_t value) in spi_conf_remove() argument
88 conf &= ~value; in spi_conf_remove()
92 static void spi_ce_ctrl(const AspeedSMCTestData *data, uint32_t value) in spi_ce_ctrl() argument
96 conf |= value; in spi_ce_ctrl()
103 uint32_t ctrl_reg = R_CTRL0 + data->cs * 4; in spi_ctrl_setmode()
104 uint32_t ctrl = spi_readl(data, ctrl_reg); in spi_ctrl_setmode() local
105 ctrl &= ~(CTRL_USERMODE | 0xff << 16); in spi_ctrl_setmode()
106 ctrl |= mode | (cmd << 16); in spi_ctrl_setmode()
107 spi_writel(data, ctrl_reg, ctrl); in spi_ctrl_setmode()
112 uint32_t ctrl_reg = R_CTRL0 + data->cs * 4; in spi_ctrl_start_user()
113 uint32_t ctrl = spi_readl(data, ctrl_reg); in spi_ctrl_start_user() local
115 ctrl |= CTRL_USERMODE | CTRL_CE_STOP_ACTIVE; in spi_ctrl_start_user()
116 spi_writel(data, ctrl_reg, ctrl); in spi_ctrl_start_user()
118 ctrl &= ~CTRL_CE_STOP_ACTIVE; in spi_ctrl_start_user()
119 spi_writel(data, ctrl_reg, ctrl); in spi_ctrl_start_user()
124 uint32_t ctrl_reg = R_CTRL0 + data->cs * 4; in spi_ctrl_stop_user()
125 uint32_t ctrl = spi_readl(data, ctrl_reg); in spi_ctrl_stop_user() local
127 ctrl |= CTRL_USERMODE | CTRL_CE_STOP_ACTIVE; in spi_ctrl_stop_user()
128 spi_writel(data, ctrl_reg, ctrl); in spi_ctrl_stop_user()
131 static void spi_ctrl_set_io_mode(const AspeedSMCTestData *data, uint32_t value) in spi_ctrl_set_io_mode() argument
133 uint32_t ctrl_reg = R_CTRL0 + data->cs * 4; in spi_ctrl_set_io_mode()
134 uint32_t ctrl = spi_readl(data, ctrl_reg); in spi_ctrl_set_io_mode() local
137 mode = value & CTRL_IO_MODE_MASK; in spi_ctrl_set_io_mode()
138 ctrl &= ~CTRL_IO_MODE_MASK; in spi_ctrl_set_io_mode()
139 ctrl |= mode; in spi_ctrl_set_io_mode()
140 spi_writel(data, ctrl_reg, ctrl); in spi_ctrl_set_io_mode()
145 spi_conf(data, 1 << (CONF_ENABLE_W0 + data->cs)); in flash_reset()
155 spi_conf_remove(data, 1 << (CONF_ENABLE_W0 + data->cs)); in flash_reset()
214 spi_conf(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); in aspeed_smc_test_read_jedec()
225 g_assert_cmphex(jedec, ==, test_data->jedec_id); in aspeed_smc_test_read_jedec()
231 uint32_t some_page_addr = test_data->page_addr; in aspeed_smc_test_erase_sector()
235 spi_conf(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); in aspeed_smc_test_erase_sector()
241 read_page(test_data, some_page_addr - FLASH_PAGE_SIZE, page); in aspeed_smc_test_erase_sector()
283 uint32_t some_page_addr = test_data->page_addr; in aspeed_smc_test_erase_all()
287 spi_conf(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); in aspeed_smc_test_erase_all()
293 read_page(test_data, some_page_addr - FLASH_PAGE_SIZE, page); in aspeed_smc_test_erase_all()
333 uint32_t my_page_addr = test_data->page_addr; in aspeed_smc_test_write_page()
338 spi_conf(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); in aspeed_smc_test_write_page()
370 uint32_t my_page_addr = test_data->page_addr; in aspeed_smc_test_read_page_mem()
378 spi_ce_ctrl(test_data, 1 << (CRTL_EXTENDED0 + test_data->cs)); in aspeed_smc_test_read_page_mem()
381 spi_conf(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); in aspeed_smc_test_read_page_mem()
393 spi_conf_remove(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); in aspeed_smc_test_read_page_mem()
413 uint32_t my_page_addr = test_data->page_addr; in aspeed_smc_test_write_page_mem()
420 spi_ce_ctrl(test_data, 1 << (CRTL_EXTENDED0 + test_data->cs)); in aspeed_smc_test_write_page_mem()
423 spi_conf(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); in aspeed_smc_test_write_page_mem()
451 spi_conf(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); in aspeed_smc_test_read_status_reg()
460 (test_data->s, test_data->node, "write-enable")); in aspeed_smc_test_read_status_reg()
470 (test_data->s, test_data->node, "write-enable")); in aspeed_smc_test_read_status_reg()
480 (test_data->s, test_data->node, "write-enable")); in aspeed_smc_test_read_status_reg()
490 spi_conf(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); in aspeed_smc_test_status_reg_write_protection()
492 /* default case: WP# is high and SRWD is low -> status register writable */ in aspeed_smc_test_status_reg_write_protection()
503 /* WP# high and SRWD high -> status register writable */ in aspeed_smc_test_status_reg_write_protection()
514 /* WP# low and SRWD low -> status register writable */ in aspeed_smc_test_status_reg_write_protection()
515 qtest_set_irq_in(test_data->s, test_data->node, "WP#", 0, 0); in aspeed_smc_test_status_reg_write_protection()
526 /* WP# low and SRWD high -> status register NOT writable */ in aspeed_smc_test_status_reg_write_protection()
538 qtest_set_irq_in(test_data->s, test_data->node, "WP#", 0, 1); in aspeed_smc_test_status_reg_write_protection()
548 spi_ce_ctrl(test_data, 1 << (CRTL_EXTENDED0 + test_data->cs)); in aspeed_smc_test_write_block_protect()
549 spi_conf(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); in aspeed_smc_test_write_block_protect()
566 uint32_t num_protected_sectors = i ? MIN(1 << (i - 1), n_sectors) : 0; in aspeed_smc_test_write_block_protect()
567 uint32_t protection_start = n_sectors - num_protected_sectors; in aspeed_smc_test_write_block_protect()
593 spi_ce_ctrl(test_data, 1 << (CRTL_EXTENDED0 + test_data->cs)); in aspeed_smc_test_write_block_protect_bottom_bit()
594 spi_conf(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); in aspeed_smc_test_write_block_protect_bottom_bit()
612 uint32_t num_protected_sectors = i ? MIN(1 << (i - 1), n_sectors) : 0; in aspeed_smc_test_write_block_protect_bottom_bit()
636 uint32_t my_page_addr = test_data->page_addr; in aspeed_smc_test_write_page_qpi()
644 spi_conf(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); in aspeed_smc_test_write_page_qpi()