# -*- shell-script -*-

# 40ibm,vpd - Hardware database scanning routines and variables for
#             systems with device-tree *and* ibm,vpd properties.

# This file is part of the Linux lsvpd package.

# (C) Copyright IBM Corp. 2002, 2003, 2004

# Maintained by Martin Schwenke <martins@au.ibm.com>

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    
# $Id: 40ibm,vpd,v 1.13 2004/06/10 04:35:56 martins Exp $

[ "$device_tree_device_type" = "chrp" ] || return 0

######################################################################

db_initialise_functions="${db_initialise_functions} db_initialise_ibm_vpd"

db_initialise_ibm_vpd ()
{
    ibm_vpd_adapter_init_hook "$db_bus_dt_dir"
}

dt_adapter_init_hooks="${dt_adapter_init_hooks} ibm_vpd_adapter_init_hook"

ibm_vpd_adapter_init_hook ()
{
    local node="$1"

    local i
    find "$node" -name 'ibm,vpd' |
    while read i ; do
	local d="${i%/*}" # dirname
	pci_render_vpd "$d"

	if [ "$d" != "$db_bus_dt_dir" ] ; then
	    local vpd_dir
	    vpd_dir_set_hook "$d"
	    if [ -e "$vpd_dir" ] ; then
		local yl
		dt_manufacture_yl_hook "$d"
		[ -n "$yl" ] && \
		    vpd_field_ensure "$vpd_dir" "YL" "$yl"
	    fi
	fi
    done
}
