/*
* Copyright (c) 2006 Michael Lorenz
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Integraphics Systems IGA 168x and CyberPro series.
* ofbus attachment for Valeriy E. Ushakov's igsfb driver
*/
int
igsfb_ofbus_cnattach(bus_space_tag_t iot, bus_space_tag_t memt)
{
struct igsfb_devconfig *dc;
int ret;
int chosen_phandle, igs_node;
int stdout_ihandle, stdout_phandle;
uint32_t regs[16];
char mode_buffer[64];
stdout_phandle = 0;
/* first find out if there's a CyberPro at all in this machine */
igs_node = OF_finddevice("/vlbus/display");
if (igs_node == -1)
return ENXIO;
if (!of_compatible_match(igs_node, compat_data))
return ENXIO;
/*
* now we know there's a CyberPro in this machine so map it into
* kernel space, even if it's not the console
*/
if (OF_getprop(igs_node, "reg", regs, sizeof(regs)) <= 0)
return ENXIO;
/*
* check if the firmware output device is indeed the CyberPro
*/
if ((chosen_phandle = OF_finddevice("/chosen")) == -1 ||
OF_getprop(chosen_phandle, "stdout", &stdout_ihandle,
sizeof(stdout_ihandle)) != sizeof(stdout_ihandle)) {
return ENXIO;
}
stdout_ihandle = of_decode_int((void *)&stdout_ihandle);
stdout_phandle = OF_instance_to_package(stdout_ihandle);
if (stdout_phandle != igs_node) {
/*
* If we aren't the boot console, the CyberPro probably
* hasn't been brought up yet. Bring it up now, it's
* still early enough to do so.
*/
const int handle = OF_open("/vlbus/display");
if (handle != -1)
OF_close(handle);
return ENXIO;
}
/* ok, now setup and attach the console */
dc = &igsfb_console_dc;
ret = igsfb_setup_dc(dc);
if (ret)
return ret;
if (of_get_mode_string(mode_buffer, sizeof(mode_buffer))) {
strcpy(dc->dc_modestring, mode_buffer);
}
ret = igsfb_cnattach_subr(dc);
if (ret)
return ret;
pa = isa_io_physaddr + offset - PCI_MAGIC_IO_RANGE;
return arm_btop(pa);
}
#endif
/*
* we also need to allow mapping of the whole aperture, including MMIO
* registers on CyberPro at its physical address
*/
if ((offset >= igsfb_mem_paddr) &&
(offset < (igsfb_mem_paddr + 0x00800000))) {
return (arm_btop(offset) | ARM32_MMAP_WRITECOMBINE);
}
if ((offset >= (igsfb_mem_paddr + 0x00800000)) &&
(offset < (igsfb_mem_paddr + 0x01000000)))
return arm_btop(offset);