|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
M! I b; @$ z* Z. w2 J#include <linux/init.h>$ y5 e: r; N. P1 H
#include <linux/module.h>% `* k h) w9 R N9 y$ A2 f/ _" t2 B
#include <linux/kernel.h>
$ N$ E$ I- ]9 x. r#include <linux/types.h>
# _; h5 K3 g. E3 c& S: {* d#include <linux/gpio.h>
2 \+ u0 @5 H/ q#include <linux/leds.h>/ S# b8 q6 j3 R: T" y
#include <linux/platform_device.h>
- S& `+ b e" A) Z. c+ J. M0 H7 b( o: U! f p3 `
#include <asm/mach-types.h>6 E, K- h# v2 b9 ^& k% h- `& m
#include <asm/mach/arch.h>! f8 w, r: b0 b# e
#include <mach/da8xx.h>
$ D0 `* Q" l {#include <mach/mux.h>: X$ Z. e$ @3 Q3 @
8 U8 {( a# m0 K3 e! P6 Y#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)/ g, \$ l' w1 ]4 O
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
6 @$ h: [6 Y' M4 |$ r2 c5 R* a, Z( C#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
7 E: k% c, P& m# ~1 `#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)8 }" v6 b, E' m+ C: c
3 h0 P1 E3 ?- j& _; n
/* assign the tl som board LED-GPIOs*/" x3 p1 {+ B8 C) |8 @
static const short da850_evm_tl_user_led_pins[] = {
' Y* G: Q3 \8 w4 p- f" \ /* These pins are definition at <mach/mux.h> file */7 Y4 K$ P* o. e1 c
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
3 e' V2 M4 p# \! p5 F -1 e' t0 R7 \: A, _9 B( m0 f
};; z7 Q" y/ X/ y5 d) x
& {0 m8 Q1 |2 q5 }$ o {" e$ x# s" Mstatic struct gpio_led da850_evm_tl_leds[] = {
. ^ [$ ]" z$ A3 o, h {7 B" Q$ |- t( b
.active_low = 0,) r1 C# ^% C1 _5 O, s% h
.gpio = DA850_USER_LED0,, W3 G7 k" D7 H0 ?: n/ A
.name = "user_led0",
& @+ ^& d4 I, U+ h( S6 Q .default_trigger = "default-on",
" f& z `; L2 F' I* _ },
) Y m( t, i+ R4 I, o3 b" k {# x, C! x" _- p2 ~ u
.active_low = 0,
$ K- }3 w, D4 h; m! t. I .gpio = DA850_USER_LED1,+ d# B$ [3 b8 I8 u, y
.name = "user_led1",
' z, I% p* S" |! \" h .default_trigger = "default-on",
5 R7 d ^% G% I },
' v Y6 D: q3 E( ~0 q% m" M0 E {3 H+ C" l8 ], ?4 q' q+ l( u
.active_low = 0,$ H) C7 _4 S9 c3 t7 G) B
.gpio = DA850_USER_LED2, {& n) O8 p; d& l/ d: P4 [
.name = "user_led2",8 M& Q4 {- s, o/ E+ o
.default_trigger = "default-on",' t& `7 p- g$ Y
},
. n6 h+ q, w" Z {
. {5 _1 \7 {/ G1 j/ m9 g .active_low = 0,7 Z8 @% J0 N; ?& U! U4 H: k
.gpio = DA850_USER_LED3,
4 V l/ N! ~' U2 A; N" x$ f .name = "user_led3",9 x2 W/ y/ X" Z$ u% g( N2 ?
.default_trigger = "default-on",7 H: L: Y; z' c `: X3 h' J2 D
},; s( D2 W) J( {+ Z
};2 a: S r0 Y% B0 x' x( L8 ^" M, ~
+ W) r5 l0 ]" U0 w. G/ [static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- a: O. {7 u! G) r) r( k
.leds = da850_evm_tl_leds,
3 y5 h" s! A h! W% w1 p: r6 n .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
' O3 h% A# R+ S+ x};
# z ]' W4 Y6 t: b8 P1 x1 S* ^
6 h7 A" d1 j; E1 ?1 Z$ i% l: Cstatic void led_dev_release(struct device *dev)6 X0 @0 X0 j3 j [- B/ f
{
! N7 X# p& F: Z9 u2 ?9 F/ @};5 q" G6 @. c ~1 E t5 q7 T- H
6 P( X6 I% v( \3 `1 l5 {% Kstatic struct platform_device da850_evm_tl_leds_device = {
: W( T4 E6 n# [4 x" U. ^. n! F' e2 G .name = "leds-gpio",3 I" f* ]( W+ V5 ^2 I7 I
.id = 1,# k9 H2 @% U/ c- M7 [9 H* ]
.dev = {
% k$ e; q, U/ F; u4 n/ x .platform_data = &da850_evm_tl_leds_pdata,
6 [, c2 C4 k! O, b: O* O .release = led_dev_release,( w. w/ z8 j7 h" [! P0 Z
}9 P! i9 {8 C7 @# C e1 D! A8 Z: B. ?
};6 {# \: x6 P ]- F7 D2 T7 u# Y
2 ^7 t" A- Q! S- ?$ Q
static int __init led_platform_init(void)
9 z6 _+ Z! K* t. q! y6 y{
" q! l6 F" M5 Z( S0 n int ret;
$ E7 ^6 m: M5 |4 _! D9 g) f#if 0 r! R( P+ T4 F/ S
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);2 B2 l* R) U. |
if (ret)" A7 L, b( R- z
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
0 l: V; a4 q M+ r "%d\n", ret);% g9 T1 ~- P" n; W7 H8 V2 B! L
#endif) A# t2 h3 Y( E( T) J0 _
ret = platform_device_register(&da850_evm_tl_leds_device);7 w f; ? X0 T( C1 U/ J
if (ret)
( F- {7 \( U2 S' i' L: K pr_warning("Could not register som GPIO expander LEDS");
6 \4 b9 _2 O2 _1 V4 g; c! a: ? else% O9 f4 C1 B2 ^+ D1 V) F9 \
printk(KERN_INFO "LED register sucessful!\n");
- B u- @$ w5 K8 D3 N5 N% K
) [! ^4 M" ?( v! x7 `- j return ret;
& a; D; W( M, @ {}2 p( e1 v9 N: u
( y( G& Q6 ~ _- W1 F& Istatic void __exit led_platform_exit(void)
/ R" W" R# ]7 y! n{
/ y4 v/ I3 p5 b4 \, p4 X platform_device_unregister(&da850_evm_tl_leds_device);
; I& H# L$ j- o3 V" R9 s
# Z' X/ H. y' U7 ^2 m* D printk(KERN_INFO "LED unregister!\n");- |7 b6 G: X& I0 ?1 V5 y6 q1 t
}
6 K9 k8 J% F8 C/ p5 ~: |* p$ h4 y' W0 u4 m' ~/ x& f) K8 {4 J+ M% E
module_init(led_platform_init);
7 {( j( x* V6 L( H. o' hmodule_exit(led_platform_exit);
5 R! O0 C5 f: i3 K3 ?$ b" W+ B4 l Q' f
MODULE_DESCRIPTION("Led platform driver");. {- b5 r0 T) Z7 J' }& A' l
MODULE_AUTHOR("Tronlong");4 W) i. i" h8 L4 i( r
MODULE_LICENSE("GPL");( J& h0 q& `" z6 Y4 H$ ]9 E* B" i
6 |1 z a, c& } |
|