1.11. pl08x_choose_master_bus

/*
 * - prefers destination bus if both available
 * - if fixed address on one bus chooses other
 */
void pl08x_choose_master_bus1(struct pl08x_bus_data *src_bus,
	struct pl08x_bus_data *dst_bus, struct pl08x_bus_data **mbus,
	struct pl08x_bus_data **sbus, union _cctl *cctl_parm)
{
	if (!cctl_parm->bits.di) {
		*mbus = src_bus;2
		*sbus = dst_bus;
	} else if (!cctl_parm->bits.si)	{
		*mbus = dst_bus;
		*sbus = src_bus;
	} else {
/* TODO: ??? */
		if (dst_bus->buswidth == 4) {
			*mbus = dst_bus;
			*sbus = src_bus;
		} else if (src_bus->buswidth == 4) {
			*mbus = src_bus;
			*sbus = dst_bus;
		} else if (dst_bus->buswidth == 2) {
			*mbus = dst_bus;
			*sbus = src_bus;
		} else if (src_bus->buswidth == 2) {
			*mbus = src_bus;
			*sbus = dst_bus;
		} else {
			/* src_bus->buswidth == 1 */
			*mbus = dst_bus;
			*sbus = src_bus;
		}
	}
}
        

1

根据传入的是源自增SI还是DI目的地址自增,决定谁是master bus

2

如果是 非DI,不是目标地址自增,那么就用src作为master bus 以实际常用的情况举例,比如要从某个buffer传输数据到nand flash的DATA寄存器中,那么就是DI为0,而作为主方向的buffer,就是master bus,从master的buffer传输到slave 的nand flash的DATA寄存器