|
求大神给下面的程序做注解,请稍详细些,谢谢。
9 m0 B4 B- w0 Y2 T7 a; o5 x" `#include <linux/init.h>
, v/ D1 \. O0 f3 y: W#include <linux/module.h>+ d, e* Q) f3 F: L" v( K C
#include <linux/kernel.h>! p$ O, R3 p3 X$ ]6 Y8 e
#include <linux/types.h>
: p _$ \1 o2 N/ j# Q#include <linux/gpio.h>& p" D# C1 v2 S+ ^1 F& l
#include <linux/leds.h>: W9 S; j5 M- H/ y5 ~3 W
#include <linux/platform_device.h>
2 u% h, B, m9 `; R+ y4 Z# S: E0 U
% k: y/ {* d4 M0 }8 B- D#include <asm/mach-types.h>( ~- p- r% b( \: a% S8 A4 X7 s$ `
#include <asm/mach/arch.h>* L; _: [$ N3 D/ B. d
#include <mach/da8xx.h>3 p+ W3 `4 h" t% i0 R: C$ D" x$ ?
#include <mach/mux.h>
7 W0 E3 Y: @" I! t6 \1 |1 N" T: O/ ]) P ^6 a r5 `2 R5 T* X
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)0 V- m7 v, P( E+ j
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)6 ?- x- d8 o6 p
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
5 D: F6 i3 V; X#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
' w* E+ P' R, N6 q2 X) v0 k5 |; u! `9 T! E# f6 ~
/* assign the tl som board LED-GPIOs*/
. U. s) d; w7 y8 estatic const short da850_evm_tl_user_led_pins[] = {
/ @2 r7 ?( G) i( D) u! n /* These pins are definition at <mach/mux.h> file */$ {/ X! }" n0 f- z/ X
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
* C' o! O; e) C) b6 \7 U" ^ -1! J" P" b7 G( _! m# [
};* G0 o R2 j* U4 n) Y& i8 A# r
0 w i" ]2 [, s' L8 @+ _ O# d6 Ostatic struct gpio_led da850_evm_tl_leds[] = {
6 S) X" Y% t' D! y4 K! h {
9 t3 {8 A8 x% V+ ]3 w& ~2 } .active_low = 0,+ q8 a% o5 K3 M( M& L1 A- g* l3 R
.gpio = DA850_USER_LED0,( @' J) {' c. S
.name = "user_led0",
" c5 d0 e0 F$ r' r5 C .default_trigger = "default-on",' Z$ `! p0 |+ p$ o5 `2 @6 |5 w
},0 m2 y. o7 {4 t
{) |& E! E/ p! l
.active_low = 0,
, m2 A$ s5 S/ _- F. V/ G6 m7 K .gpio = DA850_USER_LED1,
6 R7 a! B5 }) Z4 c- u9 W; w .name = "user_led1",
3 N# P$ W5 p' u5 y' o7 @ .default_trigger = "default-on",* v# R7 Z) d8 w2 v2 b
},
7 | s4 G: |1 U5 n) V: f! D {
9 b+ x# ]) g+ `1 ?, u' o- ^ .active_low = 0,6 x# ^4 n1 _% f) r: t
.gpio = DA850_USER_LED2,. h4 A5 E6 S- b: q9 y) |. @
.name = "user_led2",
4 J* k7 m2 g1 } .default_trigger = "default-on",
8 {5 Z! R% I/ l6 [3 U },
! f& u& T7 a' _$ f: f7 g6 v1 u- F { p5 N5 ^9 K6 N* j. j: N8 t
.active_low = 0,! }0 G' {# m3 P
.gpio = DA850_USER_LED3,
) j' W* x8 \6 c# y5 b m) U .name = "user_led3",3 z6 {& n- ?; n8 r$ m$ X" [
.default_trigger = "default-on",% H- t' ?' c S$ P& f! _( i
},
: S, f' r+ O H};0 A" H% k/ X* o/ s
( V% V' `7 a8 f' t! r$ P+ }static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
( }, {" i4 I, F x# T8 ?" c .leds = da850_evm_tl_leds,
; _" z6 R2 D' \ r( y$ r .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 A. }; U* N9 c( d- Z0 c% G* H};
" U+ ]- Y: _0 C( y% ?) A5 p
' W4 v5 w0 c' g, Pstatic void led_dev_release(struct device *dev)
) T( y% \: i% D. K{
* k$ Z2 H5 m. L: W& k1 F};5 `0 j' E; e" ~, [" t2 ?, y
" G* d$ u7 O0 [* G1 @5 d
static struct platform_device da850_evm_tl_leds_device = {
3 P& @) x+ w! b .name = "leds-gpio",4 d# ~/ a6 S3 x' r4 A4 p$ G" Z5 C
.id = 1,4 [0 W* y% ?. H7 r [% _
.dev = {
* l+ }( j f# |7 h .platform_data = &da850_evm_tl_leds_pdata,
- e/ T" o; {( y" w2 N .release = led_dev_release,, U/ c7 R' ?" {# ~ k) F
}
& C, K9 I1 f3 J8 f};
6 V$ W# p) Y# M) ` Y$ g8 P, [& e( @8 Y# T! G
static int __init led_platform_init(void)
$ T( e3 y$ U. ~{9 F; d! A1 l- r" l9 V/ `- P2 o/ L; b6 ]: V
int ret;
% O { V8 t; }' W& K6 L- @0 d#if 0
a' @; P( j' z# M8 w. q; z ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ M( g& Q3 T" i5 F- D if (ret)
V. W: x* S+ F pr_warning("da850_evm_tl_leds_init : User LED mux failed :"+ u3 `( P4 O/ |# J! T$ i
"%d\n", ret);
8 Q. p; O& f% g. c#endif: X8 r8 u4 }0 o8 z* D
ret = platform_device_register(&da850_evm_tl_leds_device);
7 v" J3 F( L! w& q; h) d4 d) J if (ret)
7 i; c; }* _6 O( R! k# g' q pr_warning("Could not register som GPIO expander LEDS");) G8 c- |, ^# M1 d* M
else
. H% P' s, L" A; V7 d printk(KERN_INFO "LED register sucessful!\n");
$ ^1 Y9 V. x# Y) c3 m
8 J4 d; M, e) ?# H return ret; ]: T. t2 V( o) y E% g6 l
}
" E; R, ^5 y" J( z
' _: x, l; @3 s! Istatic void __exit led_platform_exit(void)
; j4 \3 y7 w' U; Y) e. c{; O6 g" c, Q$ Q8 k2 G. C; ~# \
platform_device_unregister(&da850_evm_tl_leds_device);
. t; U7 t. I1 S8 i6 L9 t$ F! M( t2 M+ ]7 Z# s; x
printk(KERN_INFO "LED unregister!\n");* T' q) t; c9 Y
}; f L8 Y% ~0 r, t: X; m
) R6 B# K3 x$ ~1 X0 i$ m
module_init(led_platform_init);) E) x1 \$ d# u$ V
module_exit(led_platform_exit);8 ~ l8 W c& [9 T
8 R* {1 z+ Z1 e# ZMODULE_DESCRIPTION("Led platform driver");
! ^% W4 Z1 ]& U/ ZMODULE_AUTHOR("Tronlong");" |6 K8 I, {" ?0 n) X; _) E
MODULE_LICENSE("GPL");
: n- @ M! {( ^4 E/ U5 f0 h$ ~0 R) r
2 i1 a! W% y6 R! S ]# `& m |
|